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

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.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.