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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
jaswisai
Frequent Visitor

Applying a new filter to a column based on resulting data from slicer selection of another column

Hello all! I've been trying to solve this for an embarrasingly long time, but can't seem to think of a solution/ find one online.

Here's what I am trying to do with the data (below):
1. I want to have a slicer for product_details, this slicer will have values of product_details that only belong to one product_category (Category X).
2. Now, I want  a Bar chart, that ranks the products belonging to Category Y, based on their presence in  transaction_ids that contain the product selected using the slicer above.

For below data, assuming I have selected Product A in my slicer, I'd get a bar chart with rankings of Category Y products that are present in the transaction_id's that contain Product A.
Data:

transaction_idproduct_categoryproduct_details
TXN001Category XProduct A
TXN001Category XProduct B
TXN001Category YProduct C
TXN001Category YProduct C
TXN002Category XProduct E
TXN002Category XProduct F
TXN002Category YProduct G
TXN002Category YProduct H
TXN003Category XProduct I
TXN003Category XProduct A
TXN003Category YProduct J
TXN004Category XProduct B
TXN004Category YProduct C
TXN004Category YProduct G
TXN005Category XProduct E
TXN005Category YProduct D
TXN005Category YProduct J


Desired Output:

jaswisai_1-1724720832942.png

 

Explanation of output: TXN001 and TXN003 contain Product A (selected in slicer, belongs to Category X). In these transaction_ids, the products in Category Y, arranged in decreasing order of frequency are Product C at count 2 and Product J at count 1.

Note: At a smaller scale, I created a new table from the above data, that collects unique transaction_ids for a specific product and then applied it as a filter on transaction_ids for main data. However, there are far too many products now to be able to create a table of transaction_ids for each product.

Thanks for your time!

1 ACCEPTED SOLUTION
v-xiaocliu-msft
Community Support
Community Support

Hi @jaswisai ,

 

I made a sample for you.

vxiaocliumsft_0-1724738732489.png

vxiaocliumsft_1-1724738742789.png

vxiaocliumsft_2-1724738756786.png

vxiaocliumsft_3-1724738767893.png

Measure = var test =  VALUES(Table4[transaction_id])

 

var test2 =  COUNTROWS( FILTER(ALL(Table4), [transaction_id] in test && 'Table4'[product_details]=MAX('Table'[product_details]) ))

 

var test3 =IF( MAXX( FILTER(ALL('Table4'),'Table4'[product_details]=MAX('Table'[product_details])),'Table4'[product_category])="Category X",0,test2)

 

RETURN test3

 

Best Regards,

Wearsky

View solution in original post

2 REPLIES 2
v-xiaocliu-msft
Community Support
Community Support

Hi @jaswisai ,

 

I made a sample for you.

vxiaocliumsft_0-1724738732489.png

vxiaocliumsft_1-1724738742789.png

vxiaocliumsft_2-1724738756786.png

vxiaocliumsft_3-1724738767893.png

Measure = var test =  VALUES(Table4[transaction_id])

 

var test2 =  COUNTROWS( FILTER(ALL(Table4), [transaction_id] in test && 'Table4'[product_details]=MAX('Table'[product_details]) ))

 

var test3 =IF( MAXX( FILTER(ALL('Table4'),'Table4'[product_details]=MAX('Table'[product_details])),'Table4'[product_category])="Category X",0,test2)

 

RETURN test3

 

Best Regards,

Wearsky

Thanks @v-xiaocliu-msft ! The approach works!
I'm not that well-versed in DAX yet, so please let me know if my understanding is correct.

Table collects all unique product details.
The measure:
-Var Test, collects all unique transaction ids from Table4 (base data)
-Var Test2, counts rows (occurences) of the product selected via slicer? (Table4, where transaction id in Test and product details = MAX(Table[product_details). Here MAX(Table[product_details) would simply be the value selected via slicer?

-Var Test3, very lost on this. Inside MAXX, Table4 is filtered only to have rows that contain MAX(Table[product_details]), which would be rows of Table4 that contain the product selected in slicer. MAXX of this would simply be Category X? Since that is all that remains? And IF statement checks if this is equal to Category X, then it returns 0, else it returns Test2...?

I'm definitely confused about the implementation, so I'd appreciate your help in udnerstanding your solution 🙂

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.