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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
nelson777
Frequent Visitor

Calculation with true/ false statment

Hi there,

I have a measure with a condition that returns me 1 for TRUE and 0 for FALSE.

What do I do, to sum up, all the 1 (True) results?

 

The condition works with this logic: if the amount of alerts is greater or equal to the number of devices, so it will count as 1.

then, my right outcome in the below example would be 2 as a result of the "Measure"

 

nelson777_0-1651727591622.png

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @nelson777 
You may try

Measure1 =
SUMX (
    VALUES ( d_time[Hour Num] ),
    CALCULATE (
        VAR Client =
            MAX ( d_clients[Client Full Name] )
        VAR devices_per_client =
            CALCULATE (
                DISTINCTCOUNT ( d_devices[Device] ),
                d_clients[Client Full Name] = Client
            )
        VAR Alerts =
            CALCULATE ( [Alerts], VALUES ( f_alerts[Start Date] ) )
        VAR Tag =
            IF ( Alerts >= devices_per_client, 1, 0 )
        RETURN
            Tag
    )
)

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @nelson777 
You may try

Measure1 =
SUMX (
    VALUES ( d_time[Hour Num] ),
    CALCULATE (
        VAR Client =
            MAX ( d_clients[Client Full Name] )
        VAR devices_per_client =
            CALCULATE (
                DISTINCTCOUNT ( d_devices[Device] ),
                d_clients[Client Full Name] = Client
            )
        VAR Alerts =
            CALCULATE ( [Alerts], VALUES ( f_alerts[Start Date] ) )
        VAR Tag =
            IF ( Alerts >= devices_per_client, 1, 0 )
        RETURN
            Tag
    )
)

Hey, @tamerj1   thank you very much!

I got to resolve that before you reply to me but in a different way. However, your solution is way cleaner than mine. lol

Would you mind helping me to figure now how to get the duration sum by obeying the same rules as before?

nelson777_0-1651734442251.png

 



@nelson777 
Sure.
What is the code for duration?

I worked it out. Thanks very much!!!!!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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