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
RAHEEL
Helper I
Helper I

Top 03 on different columns based on slicer selection

Hi All,

I have two measure columns in a table dataset(i.e. products), 1st measure is reg_sales and 2nd is Promo_Sales,

I have another table which is being used as slicer/filter and it contains 2 values (i.e. Regular and Promo)

 

Now I need to diplay top 3 products with hightest reg_sales from products table when slicer selection is set to "Regular"

and 

I need to display top 3 products with highest promo_sales from products table when slicer selection is set to "Promo"

 

Thanks & Regards,

Raheel

 

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @RAHEEL,

 

From your description, [reg_sales] and [Promo_Sales] are measures , not initial columns or calculated columns, right?

 

In that case, please create measures like below:

Rank for reg = RANKX(ALL('Product'),[reg_sales],,DESC,Dense)

Rank for promo = RANKX(ALL('Product'),[Promo_Sales],,DESC,Dense)

Rank = IF(LASTNONBLANK('Slicer Table'[Regular/Promo],1)="Promo",[Rank for promo],[Rank for reg]) 

Then, add measure [Rank] to visual level filters, set its value to 'is less than or equal to' 3.

1.PNG2.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yulgu-msft
Employee
Employee

Hi @RAHEEL,

 

From your description, [reg_sales] and [Promo_Sales] are measures , not initial columns or calculated columns, right?

 

In that case, please create measures like below:

Rank for reg = RANKX(ALL('Product'),[reg_sales],,DESC,Dense)

Rank for promo = RANKX(ALL('Product'),[Promo_Sales],,DESC,Dense)

Rank = IF(LASTNONBLANK('Slicer Table'[Regular/Promo],1)="Promo",[Rank for promo],[Rank for reg]) 

Then, add measure [Rank] to visual level filters, set its value to 'is less than or equal to' 3.

1.PNG2.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
SteveCampbell
Memorable Member
Memorable Member

Hello,

 

I would reccomend unpivoting your data, so that each product has a row for each Price. To do this, open the query editor. Highlight both columns of reg_sales and Promo_Sale.On the "Transform" tab, click the dropdown for unpivot columns and select "Unpivot only Selected Columns".

 

This will give you two new columns of Attribute and Value (You can rename). Use Attribute as your slicer (or you can join this to your other table if you need other info in this table).

You can add a table visual and display your Product ID/Name and Value. On the Visual Level Filters, select Product ID/Name and change filter type to Top N. Change the input to 3 and drag in Value in the By value field.



Did I answer your question? Mark my post as a solution! Proud to be a Super User!


Connect with me!
Stay up to date on  
Read my blogs on  



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.