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

DAX sum and count lines in range

Hi everyone, 

 

I am struggling with some DAX and would really appreciate some assistance. This is the trickiest issue I have ever had to solve!

 

I have a table as above with a bunch of order date and order stage changes for an order. For each order date change entry is the number of days that the order was changed by each time. For each stage (A,B,C,D,E,F) I need to calculate the number of days and times that the order was changed during that stage. For example, the stage was changed to D, then the order date changed twice, totaling 21 days during that stage. Then the stage was changed to stage E, where it changed 15 times totaling 239 days.

 

Can split these entries into more columns if need be. 

 

Thank you in advance to anyone who can solve this problem!

 

Powerbi.png

1 REPLY 1
WillyW
Frequent Visitor

you can count days between 2 different dates with 

DATEDIFF(Date1;Date2;Interval)

like:
DATEDIFF('Table1'[ColumsWithFirstDate];'Table1'[ColumsWithSecondDate];DAY)
or
DATEDIFF('Table1'[ColumsWithFirstDate];TODAY();DAY)

 I assume you have a unique order number to which you assign your stages, dates and changes?

 

To record the number of canges I would suggest a variable that increases with each change as it is described here: https://community.powerbi.com/t5/Desktop/Increment-variable-after-condition/td-p/663156

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.

Top Solution Authors