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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
TSK
Frequent Visitor

DAX for Measure

I need help in creating measure, I have 3 tables 1) Patient Name 2) Patient Diagnosis 3) Medicene Consumed. I have linked diagnosis and medicene table with Patient Name table via ID. Now I want a measure which can calculate that how many patients are diagnosed as "Fever" and consumed "Panadol" and "Arinac". Below are the tables for reference in this case answer is 2, Patient with ID 1 and 5 are Diagnosed as Fever and Consumed "Panadol" and "Arinac". How can I achieve this via measure.

Patient Name:

IDName
1Ahmed
2Rafiq
3Saleem
4Jospeh
5David

 

Patient Diagnosis:

IDDiagnosis
1Fever
2Flu
3Flu
4Flu
5Fever

 

Medicene Consumed:

IDMedicine Name
1Panadol
1Brufen
1Arinac
2Panadol
2Arinac
3Panadol
4Panadol
5Panadol
5Arinac
1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi , @TSK 

 

You may check if the following measure helps.

Measure 1 = 
VAR tab =
    SUMMARIZE (
        'Patient Name',
        'Patient Name'[ID],
        'Patient Name'[Name],
        "flag",
        VAR _id = [ID]
        RETURN
            IF (
                LOOKUPVALUE ( 'Patient Diagnosis'[Diagnosis], 'Patient Diagnosis'[ID], _id ) = "Fever"
                    && "Arinac" IN DISTINCT ( 'Medicene Consumed'[Medicine Name] )
                    && "Panadol" IN DISTINCT ( 'Medicene Consumed'[Medicine Name] ),
                1,
                0
            )
    )
RETURN
    SUMX ( tab, [flag] )

 

Pbix attached

 

Best Regards,
Community Support Team _ Eason
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

3 REPLIES 3
v-easonf-msft
Community Support
Community Support

Hi , @TSK 

 

You may check if the following measure helps.

Measure 1 = 
VAR tab =
    SUMMARIZE (
        'Patient Name',
        'Patient Name'[ID],
        'Patient Name'[Name],
        "flag",
        VAR _id = [ID]
        RETURN
            IF (
                LOOKUPVALUE ( 'Patient Diagnosis'[Diagnosis], 'Patient Diagnosis'[ID], _id ) = "Fever"
                    && "Arinac" IN DISTINCT ( 'Medicene Consumed'[Medicine Name] )
                    && "Panadol" IN DISTINCT ( 'Medicene Consumed'[Medicine Name] ),
                1,
                0
            )
    )
RETURN
    SUMX ( tab, [flag] )

 

Pbix attached

 

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

Want to ask one more thing, if I have lots of kind of fever like, fever dengue, fever malaria, fever covid, in that case how can I catch any diagnosis which contains the word fever rather than hard coded "Fever"

Thank you, You are awesome.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Kudoed Authors