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
erp
Frequent Visitor

Days Difference between two dates in same column with duplicate dates in Power BI

I have a column with duplicate dates. I need to calculate date difference based on another column.

For example, I have Stage column with 1,2,3... repeated values . What will be function I can use to calculate date values differences for stage 1?

Thanks in Advance..

2 ACCEPTED SOLUTIONS

@erp 

maybe you can try this

measure=calculate(max(lastdate),allexcept(table,bomno))-calculate(min(lastdate),allexcept(table,bomno))





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

erp
Frequent Visitor

Thanks a lot. It worked for me...😊

View solution in original post

9 REPLIES 9
erp
Frequent Visitor

Thanks for your answers...

Jihwan_Kim
Super User
Super User

 

Picture2.png

 

Days Diff Measure : =
VAR ranking =
RANKX (
FILTER ( ALL ( 'Table' ), 'Table'[Stage] = MAX ( 'Table'[Stage] ) ),
CALCULATE ( MAX ( 'Table'[Date] ) ),
,
ASC
)
VAR result =
DATEDIFF (
CALCULATE (
MAX ( 'Table'[Date] ),
FILTER (
ALL ( 'Table' ),
'Table'[Stage] = MAX ( 'Table'[Stage] )
&& RANKX (
FILTER ( ALL ( 'Table' ), 'Table'[Stage] = MAX ( 'Table'[Stage] ) ),
CALCULATE ( MAX ( 'Table'[Date] ) ),
,
ASC
) = ranking - 1
)
),
MAX ( 'Table'[Date] ),
DAY
)
RETURN
result

 

 

https://www.dropbox.com/s/rwbkhoz3ir6d789/erp.pbix?dl=0 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


ryan_mayu
Super User
Super User

@erp 

pls provide some sample data and expected output.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




erp
Frequent Visitor

My sample data

erp_0-1624607974459.png

erp_1-1624608058008.png

 

So, I need days difference between first date and last date (in lastdate Column) based on bomno column. 

Thanks in advance..

 

@erp 

maybe you can try this

measure=calculate(max(lastdate),allexcept(table,bomno))-calculate(min(lastdate),allexcept(table,bomno))





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




1.png

Need DAX(Power BI) for no of days for Each SGNo from the Above Table.

what's the expected output? it's better to create a new postand provide the detailed info.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




erp
Frequent Visitor

Thanks a lot. It worked for me...😊

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.