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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
Super User
Super User

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.