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

Days difference between two date in a measure

Hello Everyone!!

I am trying to calculate a measure in which i am trying to calculate date difference between two coloumns that are present in seperate diffrent tables in star schema. One is date Dimension in which last date of each month is present and the other is accumulating fact table in which dates are present with respect to work flow.
Now what I am trying to do is to get date difference of one date coloumn from fact table to that of data coloumn from date dimension. 
currently i am using this dax farmula

 

DATEDIFF(max('Date dimension'[Date]),SELECTEDVALUE('fact table'[Rc Date]),DAY), ALL('Date dimension'),
'fact table'[Employee Key] in Employee,'fact table'[rc month] >=7 , 'fact table'[rc month]<= MaxDate , 'fact table'[Rcm Date] = BLANK())

which is giving me wrong result
kindly help me out .
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Is the date table joined with Fact RC date ?

Because then it will same date

In a measure to take a date diff you need three thing

1 . Min of smaller date

2. Max of bigger date 

3. A common group by (In this case it may be an Id from fact), That is forced using values or summarize 

 

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

or

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , Is the date table joined with Fact RC date ?

Because then it will same date

In a measure to take a date diff you need three thing

1 . Min of smaller date

2. Max of bigger date 

3. A common group by (In this case it may be an Id from fact), That is forced using values or summarize 

 

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

or

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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.