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
Anonymous
Not applicable

Sorting calculation of interval between one date to the other

Hi guys.

 

I created the fololowing formula to count how many days I have from one date to the other:

Days Overdue = SWITCH (
TRUE (),
MIN('Incoming payments'[Receive Date]) < MIN('Output Schweinsteiger'[DUE DATE]), DATEDIFF ( MIN('Incoming payments'[Receive Date]), MIN('Output Schweinsteiger'[DUE DATE]), DAY ),
MIN('Incoming payments'[Receive Date]) > MIN('Output Schweinsteiger'[DUE DATE]), DATEDIFF ( MIN('Incoming payments'[Receive Date]), MIN('Output Schweinsteiger'[DUE DATE]), DAY )* -1
)
 
The problem rises when I want to show the two dates as the LATEST. Then, the calculation does not reflect the difference of the two dates anymore.
How to solve it?
 
Thanks,
Diego
1 ACCEPTED SOLUTION
edhans
Super User
Super User

use MAX instead of MIN. If that doesn't work, you will need to provide some data and show where it is failing, or provide a PBIX file. See links below.

 

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Just a simplier question relating to this.

 

I have a table with many dates per rows and want to compare these dates to 30/06/2020.

What I did so far was the following:

 

 - Age = datediff(30/06/2020,'Gross 16-18'[End CAP Account],YEAR)
 
What I want from it is the interval from the 'Gross 16-18'[End CAP Account] compared to 30/06/2020

Did I use the formula wrongly?

 

Thanks heaps,

Diego

 
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

We are not clear about your requirement. Can you please share some sample data and expected results? 

 

Here are the similar threads that you could reference firstly.

https://community.powerbi.com/t5/Desktop/Days-between-based-on-slicer/m-p/491626#M229121

https://community.powerbi.com/t5/Desktop/Slicer-based-datediff/m-p/735223#M354631

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , if you are using a Measure for date diff, you need a common context to have diff. Refer my blog on this topic

https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-2-Date-Difference-Across/ba-p/934397#M451

edhans
Super User
Super User

use MAX instead of MIN. If that doesn't work, you will need to provide some data and show where it is failing, or provide a PBIX file. See links below.

 

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.