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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
klllmmm-buks
New Member

Cumulative value measure in description wise (Sales,Expenses) with filters for product

I'm trying to create a line chart that shows the cumulative sales and expenses for my two products.

I have sales and expenses data in two Excel tables. I also created cumulative amounts in each of those tables as I was unable to do it in Power BI.

I loaded the Sales and Expense tables into Power BI and then appended the two tables.

Next, I created two measures for Cumulative Sales and Cumulative Expenses using the following formulas:

Cumulative Expenses = 
CALCULATE(
    SUM('Append1'[Cumulative]),
    'Append1'[Description] = "Expenses"
)

Then, I created a line chart using the cumulative values from the above two measures.

However, the values shown in the line chart do not appear to be correct as cumulative values can not be decreased than thevalue before as there are no negative values.

klllmmmbuks_0-1734519995920.png

 

How can i correct this graph to get correct Visual.
https://github.com/KelumPerera/Collection/blob/Test/PBI_ProductWise_Cumulative_ValueVisual.pbix 

2 REPLIES 2
anmolmalviya05
Super User
Super User

Hi @klllmmm-buks, Please try to create below measure:

Cumulative Sales =
CALCULATE(
SUM('Append1'[Amount]),
FILTER(
ALLSELECTED('Append1'),
'Append1'[Date] <= MAX('Append1'[Date]) &&
'Append1'[Description] = "Sales"
)
)

Cumulative Expenses =
CALCULATE(
SUM('Append1'[Amount]),
FILTER(
ALLSELECTED('Append1'),
'Append1'[Date] <= MAX('Append1'[Date]) &&
'Append1'[Description] = "Expenses"
)
)


danextian
Super User
Super User

Hi @klllmmm-buks 

You need to make use of dimension tables to be able to graph your sales and expenses into one visual.

Create a calendar and products tables in DAX or M (sample DAX formula in the pbix), relate the columns from these dim tables to your fact tables, apply calculations on these columns and use these columns in the viz (not the ones from either sales or expenses.

CumulativeExpenses = 
CALCULATE (
    SUM ( Expenses[Amount] ),
    FILTER ( ALL ( Dates ), Dates[Date] <= MAX ( Dates[Date] ) )
)
CumulativeSales = 
CALCULATE (
    SUM ( Sales[Amount] ),
    FILTER ( ALL ( Dates ), Dates[Date] <= MAX ( Dates[Date] ) )
)

danextian_0-1734522051523.png

danextian_1-1734522074150.png

Note: While combining these two tables might be a good idea, it will lengthen the refresh time on large tables.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.