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 All
I have a data table that shows stock volume by SKU by store by week and I want to show a count of the number of stores that have a given SKU in stock in a given week.
For a matrix table I have created a count measure: if(sum('Combined Weekly Stock'[Physical Quantity])>0, 1, 0)
This returns 1 or 0 depending on whether the SKU was in stock in each store in each week.
However, this same logic also applies to the total row in the matrix table: Total physical quantity on the total row is above 1 unit so the total row shows 1.
How do I get the total row to sum all the individual counts? I would like the measure to work as it does on all rows except totals where I need it to sum the counts of the sub-rows.
The stock table holds SKUs with no stock, so I can't count occurences or rows.
Thanks!
Solved! Go to Solution.
You need to either reference your existing measure, or wrap your expression in a CALCULATE as follows
sumx(values('Combined Weekly Stock'[Store]), if(CALCULATE(sum('Combined Weekly Stock'[Physical Quantity]))>0, 1, 0))
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
@Noyer , Try like
sumx(values(Table[Store]),if(sum('Combined Weekly Stock'[Physical Quantity])>0, 1, 0))
@Noyer
This should work:
Modified Measure =
SUMX(
'Combined Weekly Stock',
if(
sum('Combined Weekly Stock'[Physical Quantity])>0,
1, 0)
)
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Assuming your Stores are on the rows, you can use an approach like this to get the "total" to show correctly. It references your existing measure, and should return the same values on the rows but the sum of those in the total. Replace with your actual table/column/measure name.
NewMeasure = SUMX(VALUES(Table[Store]), [Count Measure])
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thank you for the quick reply - your solution nearly gets me there but my count measure doesn't behave as expected. I have used:
You need to either reference your existing measure, or wrap your expression in a CALCULATE as follows
sumx(values('Combined Weekly Stock'[Store]), if(CALCULATE(sum('Combined Weekly Stock'[Physical Quantity]))>0, 1, 0))
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
@mahoneypat Thank you for taking the time to come back to me - works perfectly!
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 |
---|---|
104 | |
96 | |
79 | |
67 | |
62 |
User | Count |
---|---|
137 | |
106 | |
104 | |
81 | |
63 |