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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Bilal_321321
Helper I
Helper I

I am trying to calculate how many days a payment is over due based on a filtered date

Hi All

 

I am having an issue with calculating days overdue based on a filtered date. For example I have the following table:

ClientValueDueDays Over

Client A

10031/01/2020???
Client B10015/02/2020???
Client X20028/02/2020???
Client Z30015/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:

ClientValueDueDays Over

Client A

10031/01/202028
Client B10015/02/202013
Client X20028/02/20200
Client Z30015/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

4 REPLIES 4
v-lili6-msft
Community Support
Community Support

hi  @Bilal_321321 

First, you should know that:

  1. Calculation column/table not support dynamic changed based on filter or slicer, it is static.
    2. Measure can be affected by filter/slicer, so you can use it to get dynamic summary result.

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:

2.JPG

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you, works better than expected.

Greg_Deckler
Super User
Super User

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])


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
parry2k
Super User
Super User

@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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.