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
pmcinnis
Helper III
Helper III

How do I change DAX script to count things differently?

The table below titled 'Desired Output' shows the output I want. It's produced from the data in tables 'Results' and 'Guidelines'. 'Results' is a table of chemical concentration results. The column 'result type' is the type of sample from which the concentrations are measured. 'Guidelines' is a table of health guidelines for the various chemicals. Concentrations should be below the guidelines for public safety. 'Desired Output' counts the number of results (for each result type for each chemical) that are equal to or over the guideline and equal to or over 1/2 the guideline.

 

Annotation 2020-01-13 113206.jpg

 

The DAX script I'm using doesn't quite give me the above Desired Output table. Instead it gives me the Output table below. It counts results for chemicals f and g even though chemicals f and g don't have a guideline to compare to.

 

Annotation 2020-01-10 162458.jpg

 

Below is the DAX script I'm using. I use it to create six measures which I use to create the above table visuals. I modify the script as needed to create separate measures for result types R, T and D, as well as for comparing results to the guideline and 1/2 the guideline:

 

Annotation 2020-01-10 160554.jpg

My question is: How do I modify the above DAX script to not count results for chemicals that don't have guidelines such as chemicals f and g?

 

Thanks in advance

 

 

 

 

 

 

 

 

 

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

@pmcinnis 

 

You may add IF as follows.

IF (
    NOT (
        ISBLANK (
            CALCULATE (
                SELECTEDVALUE ( GUIDELINES[guideline] ),
                CROSSFILTER ( RESULTS[name], GUIDELINES[name], BOTH )
            )
        )
    ),

 

Community Support Team _ Sam Zha
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

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@pmcinnis 

 

You may add IF as follows.

IF (
    NOT (
        ISBLANK (
            CALCULATE (
                SELECTEDVALUE ( GUIDELINES[guideline] ),
                CROSSFILTER ( RESULTS[name], GUIDELINES[name], BOTH )
            )
        )
    ),

 

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

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.