Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I've been going for hours on this one and i cant seem to get this right.
I have two tables,
Table 1 - call it ProductPurchases - shows when a company purchased a product and how much of it
E.g
Company,Product,Quantity
CompanyA,ProductA,50
CompanyA,ProductA,20
CompanyA,ProductB,10
Table 2 - call it ProductUsage - shows when that product was used
Staff Member,Company,Product
Joe,CompanyA,ProductA
Sam,CompanyA,ProductB
I want to show a table showing how much of each product is still available
I have created a column in ProductPurchases called Consumed with DAX
When put in to a table this correctly shows how much of the product by the company is consumed
The issue is when i want to do a percentage of consumed, i use the following DAX
PctConsumed = (ProductPurchases[Consumed]/ProductPurchases[Quantity])*100
The PctConsumed never displays correctly. Any ideas on how i can make this work?
One of the problems learning DAX is that any measure is also influenced by a "filter context" generated by all the visuals on a report.
So your measure
PctConsumed = (ProductPurchases[Consumed]/ProductPurchases[Quantity])*100
probably productpurchases is being also filtered by a visual that is displaying a particular row.
To change the external filter context for a measure you use the ALL() function inside of a CALCULATE() function... so something like
PctConsumed =CALCULATE( (ProductPurchases[Consumed]/ProductPurchases[Quantity])*100, ALL(ProductPurchases))
might work.
I'm a personal Power Bi Trainer I learn something every time I answer a question
The Golden Rules for Power BI
Help when you know. Ask when you don't!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
41 | |
20 | |
19 | |
15 | |
15 |
User | Count |
---|---|
47 | |
28 | |
25 | |
17 | |
17 |