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

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
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.