cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

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

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