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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Dawn7047
Frequent Visitor

How to create an "Others" value with Top 3 products under each category with a filter on the page.

I first uploaded my query table named "Sheet1" as follows:

DUMMY_TABLE.PNG

I wanted to create a DAX expression which showed the Top 3 and Others values, so I first created a table named "PRODUCT NAMES" with all the product names along with an "Others" row:

 
PRODUCT NAMES = UNION(
                      VALUES(Sheet1[products]),
                      ROW("Product Names","Others")
)
The table was formed as follows with "Others" being denoted by the red circle:
new table.PNG
 
The Top 3 products were first denoted with the expression:
TopN = 3
 
The sum of the "Current Volume" is denoted using the formula:
Total Volume = CALCULATE(SUM(Sheet1[Current volume]))
 
A ranking was then denoted with "Others" at 4th place using the DAX expression:
 
RankbyVolume = IF(
                  SELECTEDVALUE('PRODUCT NAMES'[products])="Others",
                   [TopN]+1,
                   RANKX(
                       ALL('PRODUCT NAMES'),
                       [Total Volume])
)
The formula was used to rank products according to Total Volume" but to determine the value for "Others" I used a DAX expression to add up all values greater than the Top 3 as follows:
 
top product & others =
IF(
    [RankbyVolume]<=[TopN], [Total Volume],
    IF(SELECTEDVALUE('PRODUCT NAMES'[products])= "Others",
       SUMX(
           FILTER(
                ALL('PRODUCT NAMES'[products]),
                [RankbyVolume]>[TopN]),
             [Total Volume]
       )
    )
)
 
I then used a Pivot Table visual to display the Total Volume, RankbyVolume and top product & others values as shown below:
DUMMY_VISUAL.PNG
I then applied a filter where "top product & others"is greater than 0:
filter2.PNG
I also added category values from "Sheet1", which has 3 categories of products (alpha, beta & omega), in the row with the following results:
Capture.PNG
 The main problem is that I want a DAX expression which displays 4 rows (Top 3 products and Others ) for each category on "Sheet1" (alpha, beta & omega).
 
Does anyone have the solution to this problem?
2 REPLIES 2
v-yinliw-msft
Community Support
Community Support

Hi @Dawn7047 ,

 

Could you please tell me that you just want 4 rows in one catagory?

Top 3 and Others rows?

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Yes, I wanted to know how to display 4 rows (Top 3 products and Others) for each category (alpha, beta and omega) of products.

Apologies for not making it more clear in the question.

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors