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

If Statement Trouble

Need help for this to calculate properly. Stops at 4.
Attendance Measure =
If(sum('Monthly Goals'[Attendance Goal]) - sum(Attendance[Unexcused Hours Taken]) = 0,0,
If(sum('Monthly Goals'[Attendance Goal]) - sum(Attendance[Unexcused Hours Taken]) >=1,4,
If(sum('Monthly Goals'[Attendance Goal]) - sum(Attendance[Unexcused Hours Taken]) <=4,4,
If(sum('Monthly Goals'[Attendance Goal]) - sum(Attendance[Unexcused Hours Taken]) >4,8
))))
2 REPLIES 2
HotChilli
Super User
Super User

If the value is greater than 4 , it's also greater than 1 so it's already been dealt with.

 

Also use a variable and a switch statement instead.

AntrikshSharma
Community Champion
Community Champion

Try this:

Attendance Measure =
VAR Amount =
    SUM ( 'Monthly Goals'[Attendance Goal] ) - SUM ( Attendance[Unexcused Hours Taken] )
VAR Result =
    IF ( Amount = 0, 0, IF ( Amount >= 1 && Amount <= 4, 4, IF ( Amount > 4, 8 ) ) )
RETURN
    Result

or

Attendance Measure =
VAR Amount =
    SUM ( 'Monthly Goals'[Attendance Goal] ) - SUM ( Attendance[Unexcused Hours Taken] )
VAR Result =
    SWITCH (
        TRUE (),
        Amount = 0, 0,
        Amount >= 1 && Amount <= 4, 4,
        8
    )
RETURN
    Result

 

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