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
yaronch7
Regular Visitor

Days between the first order and the second order

How to calculate the days between the first order and the second order

 

order table :

 

account#, year,qurter,month,day

11111      2016  Q3   April    10

11111      2016  Q3   April    15

 

I want to get

 

account  daye_betwen_purchas

111111                   5

 

 

I tried to use with Matrix or to calculate with LASTDATE function , but didnt worked well , what is the recomnded approach

2 ACCEPTED SOLUTIONS
BhaveshPatel
Community Champion
Community Champion

Hi There, 

 

For such calculations, you should create a Index column in the Query Editor and Load the Query.

 

In the modelling stage, create a calculated column shown in the screenshot to view the expected result.my.PNG

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

View solution in original post

GilbertQ
Super User
Super User

Could another option not be to unpivot the data, so that you get the first order date and second order date on one column?

 

Then you could easily use the DateDiff DAX syntax (https://msdn.microsoft.com/en-us/library/dn802538.aspx?f=255&MSPPError=-2147217396)

 

 





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

Proud to be a Super User!







Power BI Blog

View solution in original post

3 REPLIES 3
GilbertQ
Super User
Super User

Could another option not be to unpivot the data, so that you get the first order date and second order date on one column?

 

Then you could easily use the DateDiff DAX syntax (https://msdn.microsoft.com/en-us/library/dn802538.aspx?f=255&MSPPError=-2147217396)

 

 





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

Proud to be a Super User!







Power BI Blog

BhaveshPatel
Community Champion
Community Champion

Hi There, 

 

For such calculations, you should create a Index column in the Query Editor and Load the Query.

 

In the modelling stage, create a calculated column shown in the screenshot to view the expected result.my.PNG

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

works fine , Thanks !!

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.