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
kmartink
Frequent Visitor

A measure using IF condition with a column reference

Hi, I'm using a slicer filtering the weeks and have made this measure to calculate how many days in a selected week was a score below 80%.
 
Low Score =
IF(
    CALCULATE(SUM('Table'[Score]))>=0.8,
    0,
    CALCULATE(DISTINCTCOUNT('Table'[Weekday]),FILTER('Table','Table'[Score]<0.8)))
 
However, the measure always returns 0 even though there were some days with a score below 80%. How can I fix it?
 
Thank you for your help.
7 REPLIES 7
kmartink
Frequent Visitor

@tamerj1 

Here is my data sample of the Score:

kmartink_2-1680093316874.png

 

And this is the visual:

kmartink_1-1680093258602.png

 

@kmartink 

I guess you are just trying to have in a card visual the count of the days that have scores less than 0.8?

if this is the case please try

Low Score =
SUMX (
DISTINCTCOUNT ( 'Table'[Date] ),
IF ( CALCULATE ( SUM ( 'Table'[Score] ) ) < 0.8, 1 )
)

Hi @tamerj1,

this is the error I get when I use your formula: The SUMX function expects a table expression for argument '1', but a string or numeric expression was used.

 

@kmartink 
Apologies, my mistake

Low Score =
SUMX (
    DISTINCT ( 'Table'[Date] ),
    IF ( CALCULATE ( SUM ( 'Table'[Score] ) ) < 0.8, 1 )
)
tamerj1
Super User
Super User

Hi @kmartink 

make sure you have created a measure not a calculated column by mistake 

Hi @tamerj1,

 

yes what I've created is a measure. I was wondering if the problem might be caused either by that the formula accidentally summarizes all the rows of the "Score" column which would mean the result would be always higher than 80% and so the zero will be displayed? Or either that my "Score" has the Data type "decimal number" and the format "percentage" but the formula uses "0.8" for 80%?

 

Is there any other way how to rewrite the formula so it might not be accidentally summing up all the rows of the column "Score" if that's the case what's happening right now? I already tried to use "AVERAGE" instead of "SUM" but there wasn't any difference. Thanks.

@kmartink 
Would you please present sample fo the data and perhaps a screenshot of the visual?

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.

Top Solution Authors