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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
astarkey
Frequent Visitor

IF Statement in a measure, Ignore IF blank

I imagine this is quite easy fro someone in the know..... WOuld be very staright forward in excel

 

I have a measure as below

service margin = [service element] - (sum(RevenueCostAnalysisViaInvJobsTable[PartsCost])+sum(RevenueCostAnalysisViaInvJobsTable[TimeCost]))

 

but I want to add an IF statement to this along the lines of IF [serivce element] is blank or zero then this measure should also return zero.

 

At the moment it returns a large negative number if [service elemet] is blank or zero because it is minusing the remaininder of the measure which is incorrect.

 

Any help appreciated

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

 

Hi astarkey,

 

Modify your measure like this pattern:

 

service margin =
IF (
    [service element] = 0
        || [service element] = BLANK (),
    0,
    [service element]
        - (
            SUM ( RevenueCostAnalysisViaInvJobsTable[PartsCost] )
                + SUM ( RevenueCostAnalysisViaInvJobsTable[TimeCost] )
        )
)

Hope it's helpful to you.

 

Jimmy Tao

 

View solution in original post

1 REPLY 1
v-yuta-msft
Community Support
Community Support

 

Hi astarkey,

 

Modify your measure like this pattern:

 

service margin =
IF (
    [service element] = 0
        || [service element] = BLANK (),
    0,
    [service element]
        - (
            SUM ( RevenueCostAnalysisViaInvJobsTable[PartsCost] )
                + SUM ( RevenueCostAnalysisViaInvJobsTable[TimeCost] )
        )
)

Hope it's helpful to you.

 

Jimmy Tao

 

Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.