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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Carly_717
Frequent Visitor

Get the value for sub category by certain %

Hi all,

I would like to get the total sales of subcategory where the main category is more than certain %

Carly_717_1-1749111034388.png

 

I would like to show all the sales of sub category where the total weightage is more or equal to 30%. 
for example, the main category that is more than 30% are "Clothes 2" and "Car"
and now, I want to get all details of item in sub category which are under "Clothes 2" and "Car".

Carly_717_0-1749111022587.png

 

How can I solve this by creating the measure in power bi ? 


Thanks in advance.

 

1 ACCEPTED SOLUTION
SamsonTruong
Super User
Super User

Hi @Carly_717 ,

One approach to this is by creating a filter flag measure. To create the measure, try using the following DAX:

FilterFlag =
VAR TotalSales = CALCULATE(SUM(SalesData[Sales]), ALL(SalesData))
VAR MainCategorySales =
    CALCULATE(
        SUM(SalesData[Sales]),
        ALLEXCEPT(SalesData, SalesData[MainCategory])
    )
VAR Weightage = DIVIDE(MainCategorySales, TotalSales)
RETURN
IF(Weightage >= 0.3, 1, 0)


Then add this measure to your filter pane and set it to where the FilterFlag is equal to 1.

SamsonTruong_0-1749112337743.png

 

This will filter your visual to all sales of sub category where the total weightage is more or equal to 30%. 

If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.

Thanks,

Samson

 

 

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

If you already have measures for [Sales] and [Weightage] you can create a new measure like

Sales for category above 30 =
VAR MainCategories =
    FILTER ( ALL ( 'Table'[Main Category] ), [Weightage] >= 0.3 )
VAR Result =
    CALCULATE ( [Sales], KEEPFILTERS ( MainCategories ) )
RETURN
    Result
SamsonTruong
Super User
Super User

Hi @Carly_717 ,

One approach to this is by creating a filter flag measure. To create the measure, try using the following DAX:

FilterFlag =
VAR TotalSales = CALCULATE(SUM(SalesData[Sales]), ALL(SalesData))
VAR MainCategorySales =
    CALCULATE(
        SUM(SalesData[Sales]),
        ALLEXCEPT(SalesData, SalesData[MainCategory])
    )
VAR Weightage = DIVIDE(MainCategorySales, TotalSales)
RETURN
IF(Weightage >= 0.3, 1, 0)


Then add this measure to your filter pane and set it to where the FilterFlag is equal to 1.

SamsonTruong_0-1749112337743.png

 

This will filter your visual to all sales of sub category where the total weightage is more or equal to 30%. 

If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.

Thanks,

Samson

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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