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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Common values on Dynamic selection

Dear Friends,

I have a serious doubt stopping me for days.I have spent enough time on forums but this is not answered anywhere.

I basically want to know - how to find the matching values (text) between two dynamic selection in a visual matrix or a table and then count the number of matching values.
------------------------------------------------
For example: I would like to know upon dynamically choosing ANY two Regional States out of 69 states, what are the matching products, in other words common products, in State 1 and State 2.

Products in state 1: Apple, Mango, Banana, Kiwi.

Products in state 2: Jackfruit, Cherry, Berry, Apple, Pineapple, Strawberry.
-----------------------------------------------------
I would like to know upon user choosing state 1 and state 2 as filter on a visual I want to the common product (Apple) to be shown and count the number of such common products. 

I believe it needs to be done by creating a measure something like;

--> CommonValues= IF( Values(State1) IN {Values(State2)},"Pull out that common value and count the number of common value", 0).
-----------------------------------------------
I would really be grateful if anyone can help me out of this.

Thank you very much in advance.

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

sreenathv_0-1617536201769.png

sreenathv_1-1617536227790.png

sreenathv_2-1617536256834.png

Measure 

 

CommonFruit = 
VAR NumberOfSelectedStates = COUNTROWS(ALLSELECTED(FruitsAndStates[State_Name]))
VAR FruitCount = COUNTROWS(FruitsAndStates)
VAR CommonCheck = IF(NumberOfSelectedStates=FruitCount,1,BLANK())
RETURN
CommonCheck

 

Filter on Visual using the measure

sreenathv_3-1617536339527.png

 

As always, there are many ways to do it. That's why I asked about your table structure. Hope this helps. Other than displaying the common fruits, if you want to count them, you could add another measure similar to this one and count the number of common fruits.

 

 

View solution in original post

ERD
Community Champion
Community Champion

Hello @Anonymous ,

Supposing states in your table might have different amount of common products and each state might have several occurancies of the same product. Also you might want to choose > 2 states..
Here are 3 measures that take into account the scenario above:

 

 

 

#1:
CommonStatePerFruitCount = 
CALCULATE(
    DISTINCTCOUNT('Common values on Dynamic selection'[State]),
    ALLSELECTED('Common values on Dynamic selection'),
    VALUES('Common values on Dynamic selection'[Fruit])
)

#2:
CommonFruitCount = 
VAR chosenStatesAmt = COUNTROWS(ALLSELECTED('Common values on Dynamic selection'[State]))
RETURN
IF(chosenStatesAmt > 1,
CALCULATE(
    DISTINCTCOUNT('Common values on Dynamic selection'[Fruit]),
    FILTER(
        ALLSELECTED('Common values on Dynamic selection'[State],'Common values on Dynamic selection'[Fruit]), 
        [CommonStatePerFruitCount] = chosenStatesAmt)
))

#3:
CommonFruitCheck = 
VAR chosenStatesAmt = COUNTROWS(ALLSELECTED('Common values on Dynamic selection'[State]))
RETURN
IF( [CommonStatePerFruitCount] = chosenStatesAmt, 1, BLANK())

 

 

Use CommonFruitCount as values in your Treemap and CommonFruitCheck for filtering the table with common products (see image below).

ERD_0-1617628861846.png

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

4 REPLIES 4
ERD
Community Champion
Community Champion

Hello @Anonymous ,

Supposing states in your table might have different amount of common products and each state might have several occurancies of the same product. Also you might want to choose > 2 states..
Here are 3 measures that take into account the scenario above:

 

 

 

#1:
CommonStatePerFruitCount = 
CALCULATE(
    DISTINCTCOUNT('Common values on Dynamic selection'[State]),
    ALLSELECTED('Common values on Dynamic selection'),
    VALUES('Common values on Dynamic selection'[Fruit])
)

#2:
CommonFruitCount = 
VAR chosenStatesAmt = COUNTROWS(ALLSELECTED('Common values on Dynamic selection'[State]))
RETURN
IF(chosenStatesAmt > 1,
CALCULATE(
    DISTINCTCOUNT('Common values on Dynamic selection'[Fruit]),
    FILTER(
        ALLSELECTED('Common values on Dynamic selection'[State],'Common values on Dynamic selection'[Fruit]), 
        [CommonStatePerFruitCount] = chosenStatesAmt)
))

#3:
CommonFruitCheck = 
VAR chosenStatesAmt = COUNTROWS(ALLSELECTED('Common values on Dynamic selection'[State]))
RETURN
IF( [CommonStatePerFruitCount] = chosenStatesAmt, 1, BLANK())

 

 

Use CommonFruitCount as values in your Treemap and CommonFruitCheck for filtering the table with common products (see image below).

ERD_0-1617628861846.png

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Anonymous
Not applicable

It is possible. Please provide your table structure with field names.

Anonymous
Not applicable

Thank you Sreenath. Please see table below.  I want PBI visual to show common fruits, Banana, upon selecting Florida and Arizona. But as you can see from the visual posted below the table it shows all the fruits in both states..

Fruit_NameState_Name
AppleFlorida
OrangeFlorida
BananaFlorida
KiwiArizona
BananaArizona
MangoArizona

 

Baba_2-1617519277044.png

 

 

Baba_1-1617519229706.png

 

 
Selecting two states from the treemap, should show onlyy the common fruit Banana on the left side table.

 

I would really appreciate your help.

 

Thank you.

 

Anonymous
Not applicable

sreenathv_0-1617536201769.png

sreenathv_1-1617536227790.png

sreenathv_2-1617536256834.png

Measure 

 

CommonFruit = 
VAR NumberOfSelectedStates = COUNTROWS(ALLSELECTED(FruitsAndStates[State_Name]))
VAR FruitCount = COUNTROWS(FruitsAndStates)
VAR CommonCheck = IF(NumberOfSelectedStates=FruitCount,1,BLANK())
RETURN
CommonCheck

 

Filter on Visual using the measure

sreenathv_3-1617536339527.png

 

As always, there are many ways to do it. That's why I asked about your table structure. Hope this helps. Other than displaying the common fruits, if you want to count them, you could add another measure similar to this one and count the number of common fruits.

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.