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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jitpbi
Post Patron
Post Patron

Calculate status

Hi,

 

I need help to get the status of a field based on few conditions. The below is the sample data where "New Stats" is the required field:

 

Output1Output2StatusNew Status
100150GoodGood
00GoodError
0100GoodError
5050NormalNormal
120130NormalNormal

 

Status field has only 2 values Good and Normal but i need to calculate 3 values in Status field based on the below conditions:

If Output1 < 5 and Output2 > 100 then "Error"

   Output1 = 0 and Output2 = 0 then "Error" 

other then above scenarios my new status field should pick the same value of the Status field. 

 

Thanks

1 ACCEPTED SOLUTION
AntrikshSharma
Super User
Super User

@jitpbi  Try this:

New Status =
VAR FirstOutput = Table[Output1]
VAR SecondOutput = Table[Output2]
VAR CurrentStatus = Table[Status]
VAR Result =
    IF (
        OR (
            AND ( FirstOutput < 5, SecondOutput > 100 ),
            AND ( FirstOutput = 0, SecondOutput = 0 )
        ),
        "Error",
        CurrentStatus
    )
RETURN
    Result

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Based on your conditions, the output in the 3rd row of your table is wrong. It should be Good, not Error.

@Anonymous Actually, the status is determined based on the values not on the pattern. Thanks
Anonymous
Not applicable

Here's your rules:

If Output1 < 5 and Output2 > 100 then "Error"
Output1 = 0 and Output2 = 0 then "Error"
other then above scenarios my new status field should pick the same value of the Status field.

Now apply those to the table you've posted and you'll see I'm right. I don't even understand what you mean by saying "the status in determined based on the values not on the pattern." What pattern are you talking about? The only thing that is used to derive the values is the rules above.... No pattern in sight.

amitchandak
Super User
Super User

@jitpbi , You can create a new column like

 

New Status =
Switch(true(),
[Output1] < 5 && [Output2] >= 100 , "Error",
[Output1] =0 && [Output2] = 0 , "Error",
"Normal"
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
AntrikshSharma
Super User
Super User

@jitpbi  Try this:

New Status =
VAR FirstOutput = Table[Output1]
VAR SecondOutput = Table[Output2]
VAR CurrentStatus = Table[Status]
VAR Result =
    IF (
        OR (
            AND ( FirstOutput < 5, SecondOutput > 100 ),
            AND ( FirstOutput = 0, SecondOutput = 0 )
        ),
        "Error",
        CurrentStatus
    )
RETURN
    Result

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.