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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
anuxps
Employee
Employee

Cumulative Running Total by Category or Department

I need a DAX forumla to get running total by Department and year and month. Here is my data sample. Assuming table name is Expenses and all these column are present in the same table.

 

DepartmentMonthYearExpenseExpenseDateRunning Total
HRJan202010001/1/20201000
HRFeb20205002/1/20201500
HRMar20203003/1/20201800
MFGFeb20205002/1/2020500
MFGMar20206003/1/20201100
SalesJan20201001/1/2020100
SalesFeb20202002/1/2020300
SalesMar20203003/1/2020600
SalesMar20204003/1/20201000
SalesFeb20205002/1/20201500
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @anuxps ,

 

Think you need to add an index column.

Check the formula and out put after add an index column.

Measure = CALCULATE(SUM('Table'[Expense]),FILTER(ALLEXCEPT('Table','Table'[Department]),'Table'[Index]<=MAX('Table'[Index])))

1.PNG

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

5 REPLIES 5
v-jayw-msft
Community Support
Community Support

Hi @anuxps ,

 

Think you need to add an index column.

Check the formula and out put after add an index column.

Measure = CALCULATE(SUM('Table'[Expense]),FILTER(ALLEXCEPT('Table','Table'[Department]),'Table'[Index]<=MAX('Table'[Index])))

1.PNG

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@anuxps , Try like

Cumm Expense = CALCULATE(SUM(Table[Expense]),filter(all(date),date[date] <=maxx(date,date[date])))

 

Cumm Expense = CALCULATE(SUM(Table[Expense]),filter(all(date),date[date] <=maxx(date,date[date]),
filter(all(Department),Department[Department] <=maxx(Department,Department[Department]))))

It is not working. All these columns are present in one table called Expenses

@anuxps , Those should work as Measure with date table.

Try this as new column

cumm = sumx(filter(Expenses, [Department] = earlier([Department]) && [ExpenseDate] <= earlier([ExpenseDate])),[Expense])

You can add additional condition to filter

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See here is the result coming which is not correct for Sales Department if you see

 

DepartmentMonthYearExpenseMeasureExpenseDatecumm
HRFeb20205005002/1/20201500
HRJan2020100015001/1/20201000
HRMar202030018003/1/20201800
MFGFeb202050010002/1/2020500
MFGMar202060029003/1/20201100
SalesFeb202070017002/1/20201600
SalesJan202010028001/1/2020100
SalesMar202070044003/1/20203000

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.