Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
aflintdepm
Helper III
Helper III

Date Parameter for Last XX reporting

I am trying to create a report that can be run at any time, but can be adjusted for historical data based on a date selected by the user.

 

I have a separate date table joined to the following data on the Target date

 

TaskTarget DateStatusDuration (in min)
Task 11/1/24Complete25 
Task 22/4/24Complete20
Task 35/1/24Complete26

 

In the resulting report, we have Last 30 Days, Last 60 Days, and Last 90 Days where we count the completed tasks, average the time to complete, etc.  I can write those calculations if the report uses "TODAY()" as the parameter.
=CALCULATE(COUNT([TASK]),[Status]="Complete], [Target Date]>=TODAY()-30 

How do I replace "TODAY()-30" with a user selected date without filtering the overall table?

 

Thank you

1 ACCEPTED SOLUTION
kpost
Super User
Super User

Use a "Before" style slicer with the Date from the Date Table, and then remove the slider bar and cover up the grayed-out start date with a non-transparent image the same color as the background, or some other visual etc.  I don't know what your report looks like so you'll have to get creative.  In any case, the goal is to be left with a single date selector box, as far as the end user is concerned.

 

But enough about aesthetics, here's the DAX.

 

Calculation_Last_30_days_from_Selected_Date = 
VAR maxdate = MAX(Date_Table[Date])

return

CALCULATE(COUNT([TASK]),[Status]="Complete], Date_Table[Date] >= maxdate - 30)

 

Difficult to say whether this will work 100% without seeing the structure of your data.  But experiment with something like this to see if you can't get it to work.

 

///Mediocre Power BI Advice, but it's free///

View solution in original post

1 REPLY 1
kpost
Super User
Super User

Use a "Before" style slicer with the Date from the Date Table, and then remove the slider bar and cover up the grayed-out start date with a non-transparent image the same color as the background, or some other visual etc.  I don't know what your report looks like so you'll have to get creative.  In any case, the goal is to be left with a single date selector box, as far as the end user is concerned.

 

But enough about aesthetics, here's the DAX.

 

Calculation_Last_30_days_from_Selected_Date = 
VAR maxdate = MAX(Date_Table[Date])

return

CALCULATE(COUNT([TASK]),[Status]="Complete], Date_Table[Date] >= maxdate - 30)

 

Difficult to say whether this will work 100% without seeing the structure of your data.  But experiment with something like this to see if you can't get it to work.

 

///Mediocre Power BI Advice, but it's free///

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.