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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
phaidara
Frequent Visitor

Cumulative measure and empty legend in barchart

Hello !

I am currently working on a inventory dashboard. I have a transaction table (day, item, category, quantity) like this one

 

Inventory tableInventory table

 

And I would like to display the inventory value per category for each day.

I have created a cumulated measure to compute the total inventory per day:

 

cumulated_quantity = 
CALCULATE(
	SUM('transactions'[quantity]),
	FILTER(
		ALLSELECTED('transactions'[day]),
		ISONORAFTER('transactions'[day], MAX('transactions'[day]), DESC)
	)
)

 

 

When I display the full inventory per day I see the expected result (day 1: 27, day 2: 24, day 3: 16)

 

Correct cumulated inventoryCorrect cumulated inventory

But when I apply the category as a legend, I notice that if there is no transaction for a given day and category, the category is not displayed in the chart:

day 1: 27 , day 2: 12, day 3: 4

Missing categories in inventory (days 2 and 3)Missing categories in inventory (days 2 and 3)

 

How can I do to display the correct inventory for those days ?

 

Thanks for your help !

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @phaidara ,

 

You will need to create an extra category table with no relationship with transactions table.

category = DISTINCT(transactions[category])

Then use below formula to get the result.

Measure = CALCULATE(SUM(transactions[quantity]),FILTER(ALLSELECTED(transactions),transactions[day]<=MAX(transactions[day])&&transactions[category]=SELECTEDVALUE('category'[category])))

1.PNG 

 

Best Regards,

Jay

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @phaidara ,

 

You will need to create an extra category table with no relationship with transactions table.

category = DISTINCT(transactions[category])

Then use below formula to get the result.

Measure = CALCULATE(SUM(transactions[quantity]),FILTER(ALLSELECTED(transactions),transactions[day]<=MAX(transactions[day])&&transactions[category]=SELECTEDVALUE('category'[category])))

1.PNG 

 

Best Regards,

Jay

Hey @Anonymous !

 

Thanks a lot, it is exactly what I was looking for !

 

amitchandak
Super User
Super User

@phaidara , Try like

 

cumulated_quantity =
CALCULATE(
SUM('transactions'[quantity]),
FILTER(
ALLSELECTED('transactions'),
'transactions'[day]>= max('transactions'[day])
&& 'transactions'[category]= max('transactions'[category])
)
)

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

Hi @amitchandak !

Thank you for your quick reply ! 

 

I've tried your solution but it does not seem to work.

Here is the new result that i got when i copied: 

new formula.PNG

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Solution Authors
Top Kudoed Authors