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
Penn
Resolver I
Resolver I

DATEDIFF Difference

Hi Everyone,

 

I have three calculated columns, and the last one is a calculated column to compare the date diff of the first two.

 

The result looks very normal in model tab, for example

 

Item ID        Date Start      Date Finish    Date Diff

S1077098   22/05/2017    23/05/2017          1

 

However when I create a table in the dashboard, it shows like this

Case ID        Date Start      Date Finish    Date Diff

S1077098   22/05/2017    23/05/2017          3

 

I guess this has something to do with row level, becuase I have three status for this case. How should I fix this?

 

The DAX that I used to calcute the date diff is 

DateDiff = DATEDIFF('TableA'[Status Start Date], 'TableA'[Status Finish Date], DAY)
 
Thank you

 

 

1 ACCEPTED SOLUTION

It would be on that field dropdown. It may not be first/last. I was looking at another model with text. But could be min/max, which would be the same in this case.

 

Not a big fan of this approach, as I prefer measures, but seeing if we can get you what you want without starting over with where your data calculations are.

 

20190307 15_46_27-PBID Sales Tax Return Filing Status - Power BI Desktop.png



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
edhans
Super User
Super User

Just throwing this out there. It may be that you have 3 records for that case ID, and DateDiff of 1 3 times is 3. If that is what is happening, you could tell it to not summarize that data in the data setting for that field. Or set to FIRST or LAST as it should be the same.

 

Or create a measure that does the calculation at the aggregate level of your table vs calculated columns. Without seeing your table, it would be something along the lines of:

 

Date Difference =
DATEDIFF ( MAX ( DataTable[Date Start] ), MAX ( DataTable[Date Finish] ), DAY )


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

Hi @edhans 

 

Can you explain more about the first option? How to get it not summarize that data in the data setting for that field. And how to set to FIRST or LAST? Thanks

It would be on that field dropdown. It may not be first/last. I was looking at another model with text. But could be min/max, which would be the same in this case.

 

Not a big fan of this approach, as I prefer measures, but seeing if we can get you what you want without starting over with where your data calculations are.

 

20190307 15_46_27-PBID Sales Tax Return Filing Status - Power BI Desktop.png



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

Thanks! @edhans 

The DAX works fine and I will look into the first option

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.