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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
gleatherman
Regular Visitor

Count of specific values in a visual

I have a table that has sales entries:

Name | Location | Type | Quantity | Date

Bob  |  Location A | Type 1 | 3 | 1-1-2024

John  |  Location A | Type 2 | 3 | 1-2-2024

Bob  |  Location A | Type 2 | 3 | 1-2-2024

Bob  |  Location A | Type 1 | 4 | 1-1-2024

 

I have Slicers to select the Location and Dates for the page.

 

I have a Matrix visual: It has Name in the Rows, Type in the Columns, and sum of quantity as the Values.

 

So it looks like this:

Name | Type 1 | Type 2 | Total

John | 0 | 3 | 3

Bob | 7 | 3 | 10

Totals | 7 | 6 | 13

 

I have an existing Card giving me the Count of Distinct Names in the selected Location/Date range.

 

I would like to add a Card visual that tells me how many distinct Names have less than 33% "Type 1" quantities for the selected location/date range vs their Total quantities.   

 

So in the example above, John has 0% Type 1, Bob has 70% Type 1; therefore, there should be a count of 1 person below 33% Type 1.

 

Once I get that... or perhaps instead of that Card... I'd like to create a second page that has a table/matrix visual that summarizes it by Location:  Location|Count of Names|Count of Names below 33% 'Type 1'

 

Thanks for any help you can give.

1 ACCEPTED SOLUTION
gleatherman
Regular Visitor

I went a different direction.

 

I created a Measure for Sum of Type 1:

SumType1 = CALCULATE(sum(sales[Quantity]),sales[Type]="Type 1")
 
I created a Measure for the percentage of total for Type 1:
Percent Total = [SumType1] / SUM(sales[Quantity]) * 100
 
And then for the Count of people under a certain percentages I made this Measure using the Summarize function:
 
Count Under 45% =

var _table = SUMMARIZE(sales,sales[Name],"Sales Total",SUM(sales[Quantity]),"Type 1",sales[SumType1],"Percent 1",[Percent Total])

return

COUNTROWS(FILTER(_table,[Percent 1]<45))

 

Probably could have done it better differently, but if it works, it works!

Now to apply this to my real data.

gleatherman_1-1704486385390.png

 

 

 

View solution in original post

6 REPLIES 6
gleatherman
Regular Visitor

I went a different direction.

 

I created a Measure for Sum of Type 1:

SumType1 = CALCULATE(sum(sales[Quantity]),sales[Type]="Type 1")
 
I created a Measure for the percentage of total for Type 1:
Percent Total = [SumType1] / SUM(sales[Quantity]) * 100
 
And then for the Count of people under a certain percentages I made this Measure using the Summarize function:
 
Count Under 45% =

var _table = SUMMARIZE(sales,sales[Name],"Sales Total",SUM(sales[Quantity]),"Type 1",sales[SumType1],"Percent 1",[Percent Total])

return

COUNTROWS(FILTER(_table,[Percent 1]<45))

 

Probably could have done it better differently, but if it works, it works!

Now to apply this to my real data.

gleatherman_1-1704486385390.png

 

 

 

Dangar332
Super User
Super User

hi, @gleatherman 

try below measure 

 

Percent of Row Total =
var a = sumx(filter(tablename,tablename[type]="type 1"),tablename[quantity])
var b = calculate(sum(tablename[quantity]),allexcept(tablename,tablename[name]))
var c = divide(a,b)
return
 calculate(count(tablename[name]),c <0.33)

I'm getting this error about True/False expressions, am I mistyping? 'sales' is the table name.

gleatherman_0-1704481675788.png

 

hi, @gleatherman 

 

Percent of Row Total =
var a = sumx(filter(tablename,tablename[type]="type 1"),tablename[quantity])
var b = calculate(sum(tablename[quantity]),allexcept(tablename,tablename[name]))
var c = divide(a,b)
return
 calculate(count(tablename[name]),filter(tablename,c <0.33))
gleatherman
Regular Visitor

That was erroring out as [Total Quantity] didn't exist so I had to modify it to calculate total quantity.

That gives me a Percent Total row for each person.

 

What I need now is a way to count the number of people who have less than a certain percentage.  So in my current example

gleatherman_0-1704472352178.png

I'd like to count the number of people who have less than a certain value in the 'PercentTotal' measure and put it on a card next to the matrix.   If I add the 'PercentTotal' measure to a card, I get the 'PercentTotal'of the the totals of the matrix, which is expected, but not what I would like it to show.   

 

I'm not sure how to evaluate each row of the measure to count the amount of people below a certain percentage.

 

amustafa
Solution Sage
Solution Sage

Assuming your tabke name is 'Sales', try this measure:

 

Percent of Row Total =
DIVIDE(
    SUM(Sales[Quantity]),
    CALCULATE(
        [Total Quantity],
        ALLEXCEPT(Sales, Sales[Name])
    )
)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors