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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
apalacios
Frequent Visitor

Conditional Running Total with DAX

I have a table with 2 columns: ID and Numbers; and I want to create a new column Result with the running total of the Numbers column but every time the running total surpass 20, the running total should be restarted. Also, if the running total is lower than 20, the result should not be displayed. This have to be done using DAX only.

Thanks in advice.

 

Note: the Conditional Running Total column exist just to show how the running total works.

ID Numbers ConditionalRunningTotal Result
IDNumbers  ConditionalRunningTotal   Result
199 
2716 
392525
488 
5917 
692626
711 
801 
901 
10910 
11919 
1222121
1311 
1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @apalacios 

 

I haven't thought of an easier way yet, the following method can achieve your needs first.

Column:

Sum = SUMX(FILTER('Table',[ID]<=EARLIER('Table'[ID])),[Numbers])
Sum 1 = IF([Sum]<20,[Sum],IF([ID]=CALCULATE(MIN('Table'[ID]),FILTER('Table',[Sum]>20)),[Sum],BLANK()))
Sum 2 = SUMX(FILTER('Table',[ID]<=EARLIER('Table'[ID])&&[ID]>CALCULATE(MIN('Table'[ID]),FILTER('Table',[Sum]>20))),[Numbers])
Sum 3 = IF([Sum 2]<20,[Sum 2],IF([ID]=CALCULATE(MIN('Table'[ID]),FILTER('Table',[Sum 2]>20)),[Sum 2],BLANK()))
Sum 4 = SUMX(FILTER('Table',[ID]<=EARLIER('Table'[ID])&&[ID]>CALCULATE(MIN('Table'[ID]),FILTER('Table',[Sum 2]>20))),[Numbers])
Sum 5 = IF([Sum 4]<20,[Sum 4],IF([ID]=CALCULATE(MIN('Table'[ID]),FILTER('Table',[Sum 4]>20)),[Sum 4],BLANK()))
Sum 6 = SUMX(FILTER('Table',[ID]<=EARLIER('Table'[ID])&&[ID]>CALCULATE(MIN('Table'[ID]),FILTER('Table',[Sum 4]>20))),[Numbers])
ConditionalRunningTotal = IF([Sum 1]<>BLANK(),[Sum 1],IF([Sum 3]<>BLANK(),[Sum 3],IF([Sum 5]<>BLANK(),[Sum 5],[Sum 6])))
Result = IF([ConditionalRunningTotal]<20,BLANK(),[ConditionalRunningTotal])

vzhangti_0-1644828612576.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @apalacios 

 

I haven't thought of an easier way yet, the following method can achieve your needs first.

Column:

Sum = SUMX(FILTER('Table',[ID]<=EARLIER('Table'[ID])),[Numbers])
Sum 1 = IF([Sum]<20,[Sum],IF([ID]=CALCULATE(MIN('Table'[ID]),FILTER('Table',[Sum]>20)),[Sum],BLANK()))
Sum 2 = SUMX(FILTER('Table',[ID]<=EARLIER('Table'[ID])&&[ID]>CALCULATE(MIN('Table'[ID]),FILTER('Table',[Sum]>20))),[Numbers])
Sum 3 = IF([Sum 2]<20,[Sum 2],IF([ID]=CALCULATE(MIN('Table'[ID]),FILTER('Table',[Sum 2]>20)),[Sum 2],BLANK()))
Sum 4 = SUMX(FILTER('Table',[ID]<=EARLIER('Table'[ID])&&[ID]>CALCULATE(MIN('Table'[ID]),FILTER('Table',[Sum 2]>20))),[Numbers])
Sum 5 = IF([Sum 4]<20,[Sum 4],IF([ID]=CALCULATE(MIN('Table'[ID]),FILTER('Table',[Sum 4]>20)),[Sum 4],BLANK()))
Sum 6 = SUMX(FILTER('Table',[ID]<=EARLIER('Table'[ID])&&[ID]>CALCULATE(MIN('Table'[ID]),FILTER('Table',[Sum 4]>20))),[Numbers])
ConditionalRunningTotal = IF([Sum 1]<>BLANK(),[Sum 1],IF([Sum 3]<>BLANK(),[Sum 3],IF([Sum 5]<>BLANK(),[Sum 5],[Sum 6])))
Result = IF([ConditionalRunningTotal]<20,BLANK(),[ConditionalRunningTotal])

vzhangti_0-1644828612576.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@apalacios , if ConditionalRunningTotal is a measure then try  a measure like

 

if([ConditionalRunningTotal]<20, blank(), [ConditionalRunningTotal])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

The column Conditional Running Total dont exists....

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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