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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Jim_PBI
Frequent Visitor

DAX (CALCULATE/SUMX) to calculate percentage of category that has reached 100%. Tableau(INCLUDE).

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. 

 

SalesAgentIDProductBarcodeIDProductCategoryProductSubCategoryProductWithAgentProductSoldByAgent
11FurnitureChair11
12FurnitureChair11
13FurnitureDesk11
14FurnitureBed11
15TechMonitor11
17TechKeyboard11
211FurnitureBed10
212FurnitureBed11
213FurnitureBed10
314TechMonitor11
315TechMonitor11
1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

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

 

Fowmy_0-1622371391298.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Fowmy
Super User
Super User

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

 

Fowmy_0-1622371391298.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Jim_PBI
Frequent Visitor

Thank you very much - exactly what I needed 🙂

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.