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

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

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

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
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
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!