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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
harry_pbi
Frequent Visitor

Dynamic selection of column and showing visuals just for a specific value from that column

Hi,

I have table "A" with "Col1" and "Col2" columns, both of which contain just TRUE or FALSE values. In that table are also many other columns. In another disconnected table "B" I have just one column with two rows with the names of these two columns, "Col1" and "Col2". 

Now, in slicer user selects for example "Col1". I want to show visuals only for rows from table "A" which contain TRUE in "Col1".

 

In other words, how to dynamically select column ("Col1" or "Col2") and show visuals just for TRUE values in that selected column.

Thank you for advice.

 

 

3 REPLIES 3
harry_pbi
Frequent Visitor

Found solution:

 
Media Spend Real = CALCULATE(
    SUM(A[Media Spend]),
    SWITCH(SELECTEDVALUE(B[Campaign Category]),
        "Col1", A[Col1],
        "Col2", A[Col2],
        "Col3", A[Col3],
        BLANK()
    ))
 
 
v-yueyunzh-msft
Community Support
Community Support

Hi , @harry_pbi 

According to your description, you want to "dynamic selection of column and showing visuals just for a specific value from that column".

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1683084780061.png

 

(2)We can create a measure :

Measure = var _slicer = VALUES('Table 2'[Value])
var _Col1=SELECTEDVALUE('Table'[Col1])
var _Col2 = SELECTEDVALUE('Table'[Col2])
return
IF( NOT(ISFILTERED('Table 2'[Value])),1,
IF(OR( {"Col1"} in _slicer && _Col1 = TRUE() ,{"Col2"} in _slicer && _Col2 = TRUE())    ,1,0))

 

(3)Then we can put the measure on the "Filter on thsi visual" and we can get the result as follows:

vyueyunzhmsft_1-1683084881931.png

 

 

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Hi Aniya,
thank you for your reply. I've tried it and found this issues:

Let's add another "Table" viz which contains just "Index" column, with the "Filter on this visual" set as you proposed.
And let's change the value of "Index" in the second row from 2 to 1 in the first "Table" to create the situation, where for one value in "Col1" exist two different values of TRUE and FALSE in "Col2".

harry_pbi_0-1683213405609.png

 

Now if we select "Col2" in the slicer, we get in that new viz just 3,7,8,9,10 without 1.
Or if we add "Card" viz with the sum of "Index" we get 54 instead of 38 without the option to define "Filter on this visual" with your "Measure".

harry_pbi_1-1683213507097.png

20230503filter_2.pbix 

 

 

I have data, where one online campaign may belogn to more categories ("Mobile" ~ "Col1", "TV" ~ "Col2",...) and user can select which category wants to see. For example trend of impressions over the year by week in Line chart for category "TV".
The column "TV" is not present in that viz, it's used just for filtering.
Do you have any idea, how to deal with that?
Thank you.

harry

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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