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
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
v-jayw-msft
Community Support
Community Support

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

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

4 REPLIES 4
v-jayw-msft
Community Support
Community Support

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

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

Hey @v-jayw-msft !

 

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])
)
)

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