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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors