Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi All
I am having an issue with calculating days overdue based on a filtered date. For example I have the following table:
Client | Value | Due | Days Over |
Client A | 100 | 31/01/2020 | ??? |
Client B | 100 | 15/02/2020 | ??? |
Client X | 200 | 28/02/2020 | ??? |
Client Z | 300 | 15/02/2020 | ??? |
I want Days Over column to be calculated based on a date filter i select, so for example i select the date 28/02/2020 the following will be filled in:
Client | Value | Due | Days Over |
Client A | 100 | 31/01/2020 | 28 |
Client B | 100 | 15/02/2020 | 13 |
Client X | 200 | 28/02/2020 | 0 |
Client Z | 300 | 15/02/2020 | -15 |
I am able to create a report that calculates days over based on todays date using 'Days Over = Today()-[Due]' but i want to be able to change the 'Today()' part to a date i have filtered.
Hope that makes sense.
Thanks in advance
First, you should know that:
https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/
Second, for your case, you need to create a measure as this way
Step1:
You need a separate date table for the slicer.
Step2:
Then create a measure as below:
Days Over = DATEDIFF(SELECTEDVALUE('Table'[Due]),SELECTEDVALUE('Date for slicer'[Date]),DAY)
Step3:
then drag them into a table visual:
and here is sample pbix file, please try it.
Regards,
Lin
Thank you, works better than expected.
Create a separate Date/Calendar table using CALENDAR or CALENDARAUTO function. Put the Date column from this in a slicer. Then replace TODAY with SELECTEDVALUE('Calendar'[Date])
@Bilal_321321 same this add as a measure
Days Over = SELETEDVALUE ( DateTable[SelectedDate] ) - SELECTEDVALUE ( Table[Due] )
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
86 | |
81 | |
53 | |
37 | |
35 |