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
Anonymous
Not applicable

slicer with conditions - if value selected,select related values

i have 2 tables

table 1 - list of all codes

 code id,  code text

code id

text

x41acdt poisn
x42acdt poisn narc
y11acdt poisn othr
y12acdt poisn aaa
i26.0pulmonary acute 
i26.9pulmonary WO acute 
J96.0acute respiratory
d68.3disosrder
g21.1other drug
g24.0drug induced
y46adverse effects
y47tri adverse
y49ana adverse

 

table 2 with patient details

patientname, admissiondate, discharge date, codeid,codetext

 

 (3rd table / new requirement)

3rd table contains 4 columns

 

diagnosiscodecode textexternal codes
pulmonary embolismi26.0pulmonary acute  
pulmonary embolismi26.9pulmonary WO acute  
drug related complicationsJ96.0acute respiratoryx41,x42,y11,y12
haemorrhagic disorderd68.3disosrder 
moment disorderg21.1other drugy46,y47,y49
moment disorderg24.0drug inducedy46,y47,y49
serious alterationr40.0somnolencey46,y47,y49
serious alterationr40.1stupory46,y47,y49
serious alterationr40.2comay46,y47,y49

 

in slicer when u select a code from table 3

it needs to filter that code and filter other external cause codes as shown in table 3

 

for example if you select j96.0 it needs to select j96.0 and other external codes x41,x42,y11 and y12

in another scenario if i26.0 is selected then just select all records realted to code i26.0 only(  no associated codes to select)

 

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

Hi @Anonymous ,

 

Based on your description, you can create a measure as follows.

 

Measure =

var _id = MAX(Table1[code id])

return

IF(

    OR(

        _id in DISTINCT(Table3[code]),

        SUMX(

            ADDCOLUMNS(

                DISTINCT(Table3[external codes]),

                "Re",

                IF(

                    CONTAINSSTRINGEXACT([external codes],_id),

                    1,0

                )

            ),

            [Re]

        )>0

    ),

    1,0

)

 

Then drag the measure to “filters on measure” and filter the visual when “measure is 1”.

v-yuaj-msft_0-1605165363882.png

 

Result:

v-yuaj-msft_1-1605165363883.png

 

v-yuaj-msft_2-1605165363885.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

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-yuaj-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, you can create a measure as follows.

 

Measure =

var _id = MAX(Table1[code id])

return

IF(

    OR(

        _id in DISTINCT(Table3[code]),

        SUMX(

            ADDCOLUMNS(

                DISTINCT(Table3[external codes]),

                "Re",

                IF(

                    CONTAINSSTRINGEXACT([external codes],_id),

                    1,0

                )

            ),

            [Re]

        )>0

    ),

    1,0

)

 

Then drag the measure to “filters on measure” and filter the visual when “measure is 1”.

v-yuaj-msft_0-1605165363882.png

 

Result:

v-yuaj-msft_1-1605165363883.png

 

v-yuaj-msft_2-1605165363885.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

MFelix
Super User
Super User

Hi @Anonymous ,

 

I assume that both tables are unrelated so create the following measure:

filter =
IF (
    SELECTEDVALUE ( 'Codes'[code id] ) IN VALUES ( 'Requirements'[code] )
        || SELECTEDVALUE ( 'Codes'[code id] ) IN VALUES ( 'Requirements'[external codes] );
    "Symptom"
)

 

Now you can use this column to filter out other visualizations.

 

MFelix_0-1605025026589.png

 

MFelix_1-1605025038420.png

 

MFelix_2-1605025049169.png

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



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.