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 everyone,
I'm relatively new to DAX and stuck on a particular problem. I would like to build a gauge chart that shows the percentage of sales agents that have sold all of their products. I have included filters on the page for SalesAgentID, ProductCatgeory and ProductSubCategory. The formula would be something similar to DIVIDE(DISTINCTCOUNT(SalesAgentID (*where SUM(ProductWithAgent)=SUM(ProductSoldByAgent*)),DISTINCTCOUNT(SalesAgentID)).
It would need to dynamically recalculate with the context of the filter so that only data after the filter is included. I have tried various CALCULATE, SUMX, Calculated Table functions with little success. In Tableau I would have tried a LOD INCLUDE calculation.
Sample data is below and any help is very much appreciated.
SalesAgentID | ProductBarcodeID | ProductCategory | ProductSubCategory | ProductWithAgent | ProductSoldByAgent |
1 | 1 | Furniture | Chair | 1 | 1 |
1 | 2 | Furniture | Chair | 1 | 1 |
1 | 3 | Furniture | Desk | 1 | 1 |
1 | 4 | Furniture | Bed | 1 | 1 |
1 | 5 | Tech | Monitor | 1 | 1 |
1 | 7 | Tech | Keyboard | 1 | 1 |
2 | 11 | Furniture | Bed | 1 | 0 |
2 | 12 | Furniture | Bed | 1 | 1 |
2 | 13 | Furniture | Bed | 1 | 0 |
3 | 14 | Tech | Monitor | 1 | 1 |
3 | 15 | Tech | Monitor | 1 | 1 |
Solved! Go to Solution.
@Jim_PBI
I think you wanted this measure:
Sold All Product % =
DIVIDE(
SUMX(
VALUES(Table2[SalesAgentID]),
INT(CALCULATE(SUM(Table2[ProductWithAgent])) = CALCULATE(SUM(Table2[ProductSoldByAgent])))
),
COUNTROWS(VALUES(Table2[SalesAgentID]))
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@Jim_PBI
I think you wanted this measure:
Sold All Product % =
DIVIDE(
SUMX(
VALUES(Table2[SalesAgentID]),
INT(CALCULATE(SUM(Table2[ProductWithAgent])) = CALCULATE(SUM(Table2[ProductSoldByAgent])))
),
COUNTROWS(VALUES(Table2[SalesAgentID]))
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Thank you very much - exactly what I needed 🙂
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 |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |