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
ganchevd
Helper I
Helper I

Difference between due date and selected calendar date

Hello,

 

I have an issue by making the calendar slicer affect the days overdue. From the table bellow:

 

Customer nameCust No.Document dateDocument No.:Due dateInvoicedEnding balance
BATHBASH20439867804.12.201710001283014.12.2017341.78341.78
MENIN2501401.03.201810001330831.03.2018600.00600.00
ASYAS20251021011.04.201810001352514.04.2018126.00126.00
LOANGROUP20508824803.05.201810001359806.05.201884.0084.00
CENTURY20459176602.05.201810001358912.05.20181 144.921 144.92
OK CORP10176716502.05.201810001358412.05.2018120.00120.00

 

I'd like to add another column called "Days Overdue", which to return the number of overdue days, based on the selected date from my calendar table. I've tried som variations of DATEDIFF but neither worked. I have a separate calendar table, linked with the DataTable, One to Many.

 

I would appreciate it very much if you help me with this issue. I think I am very close but not exactly.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

You would need to create a measure, which should be something like:

 

Measure = 
VAR MaxDate = MAX('Calendar'[Date]) // Or MAXX(ALLSELECTED('Calendar'),[Date])
VAR DueDate = MAX('Table'[Date])
RETURN DATEDIFF(MaxDate,DueDate,DAY)

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

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

You would need to create a measure, which should be something like:

 

Measure = 
VAR MaxDate = MAX('Calendar'[Date]) // Or MAXX(ALLSELECTED('Calendar'),[Date])
VAR DueDate = MAX('Table'[Date])
RETURN DATEDIFF(MaxDate,DueDate,DAY)

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

Thank you. It is working. It changes dates but when I try to add the column into the table above it breaks. Probably something with the link between calendar table and the data table. Is there any difference if the Calendar Table is prepared in Power Query Mode? Is there a way to do it as Calculated column. Since the data is huge and it is refreshing very slowly. I tried to put the same formula in Column, but it did not work properly. I received one and the same value for each of the rows.

@ganchevd,

 

Values in a calculated column are fixed. They are an immutable result for each row in the table.

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

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.