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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Measure for DateDiff

Can someone help me out with the datediff measure for a list of different Stages and different Quotes

 

Have a look at the screenshot below

 

Stage.jpg

9 REPLIES 9
Thejeswar
Super User
Super User

Hi @Anonymous,

DateDiff should be used as a Column, not a measure

 

Difference = DATEDIFF(Table1[Last Modified], TODAY(), DAY)

If this solves, accept the solution and give a kudos!!

Anonymous
Not applicable

@Thejeswar

 

Your measure does not give an accurate result. See the screenshot below.

I need the first row in the (Diffrence Collumn) of every new Q No to be empty; start of new start stage change, just like my ealier posting !

 

image.png

Hi BDA2,

 

To achieve your requirement, firstly you need to create a calculate column [Index By Q No]  to set index for every group using DAX below:

Index By Q No = RANKX(FILTER(Table1, Table1[Q No] = EARLIER(Table1[Q No])), RANKX(ALL(Table1), Table1[Last Modified]), , DESC, Dense)

Then create a calcualte column to calculate datediff which is your expected result:

DateDiff = 
VAR Previous_Date = CALCULATE(MAX(Table1[Last Modified]), FILTER(Table1, Table1[Index By Q No] = EARLIER(Table1[Index By Q No]) - 1 && Table1[Q No] = EARLIER(Table1[Q No])))
RETURN 
DATEDIFF(Previous_Date, Table1[Last Modified], DAY)

2.PNG 

 

Hope it's helpful to you.

 

Jimmy Tao

Anonymous
Not applicable

Hi @v-yuta-msft,

 

Appreciate your sharing.

 

However, when I used measure for Index By Q No, I have multiple tables. I have trouble finding EARLIER function in my table and "Dense" is gray out. Refer photo screenshot:-

image.png

 

Once I solve the above Index By Q No, only can I used measure for DateDiff.

 

Let me know your thoughts

 

Thank You

Anonymous
Not applicable

Hi @v-yuta-msft

 

Let  me know if you have a way to solve my queries 

Hi BDA2,

 

You should create calculate column, not measure.

 

Regards,

Jimmy Tao

Anonymous
Not applicable

@v-yuta-msft

It works thank you

Anonymous
Not applicable

hi @v-yuta-msft

 

Apparently I came to notice that the formula applies if my stages are distinct/not duplicated.

How should I get the same output for multiple duplicated stages for the same quote ?

Anonymous
Not applicable

@v-yuta-msft @Thejeswar

 

I am still having error for other dashboard I build and the formula does not seems to be accurate. Refer below screenshot.

The index By Q No is not in sequence and the date diff measure shows wrong calculation.

 

image.png

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.