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?
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.
André Arnaud de Cal...
291,996
Super User 2025 Season 1
Martin Dráb
230,853
Most Valuable Professional
nmaenpaa
101,156