Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Unanswered

Specify Dynamic Filter in Measure

(0) ShareShare
ReportReport
Posted on by 8

Hello:  I have Two segments that I need to create.
1-Last Appointment Date

2-Next Appointment Date

There's an Appointment Entity that has a field, ApptDate - the logic for the first one is MAX(APPTDATE) where ApptDate < Today  . And for next, it's MIN(APPTDATE) where AppDate > Today

Creating the measure itself isn't a problem, but the second condition is where i'm having a problem. I can use the Filter to  specify the condition but it looks like I can only do it with effectively a hard coded date.  Is there any way to accomplish this with a built-in field or token that would evaluate to Today, whenever it's run?

  • Brian Stubelt Profile Picture
    Brian Stubelt 2 on at
    RE: Specify Dynamic Filter in Measure

    As far as I'm aware I don't know of any dynamic filters, but if someone else does I'd love to learn. My only thought which is a bit convoluted would be to create a new data source and create a date table that has a column that compares if the date is today and mark it as 'Today'. Then create a measure of like First date that equals 'Today' in that column (there should only be one). THEN use that measure output to compare in another measure. You can just have that date table refresh automatically at midnight every day and the IsToday column should update.

    I took a stab at the power query for the date table. You shouldn't even need to bring it through M3 to use it in a measure.

    let

     Source = List.Dates(#date(2022,01,01), 365*7, #duration(1,0,0,0)),

     #"Converted to table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),

     #"Changed column type" = Table.TransformColumnTypes(#"Converted to table", {{"Column1", type date}}),

     #"Renamed columns" = Table.RenameColumns(#"Changed column type", {{"Column1", "Date"}}),

     #"Added custom" = Table.TransformColumnTypes(Table.AddColumn(#"Renamed columns", "IsToday", each if [Date] = Date.From(DateTime.LocalNow()) then "Today" else "No"), {{"IsToday", type text}}),

     #"Changed column type 1" = Table.TransformColumnTypes(#"Added custom", {{"Date", type datetime}})

    in

     #"Changed column type 1"

    Hopefully that makes some sense. Like I said, a bit convoluted, but I think it could work.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans