cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
datanau001
Helper III
Helper III

DAX Calculated column if statement (KPI Indicator)

Dear all,

 

I’m trying to create an indicator column in Dax using IF condition which will test the following:

 

KPI Indicator =

IF ('V_SR_STATUS_LINES_SEC'[Total Audit Time Hrs] < 'V_SR_STATUS_LINES_SEC'[SPE KPI] ,

    "KPI Met",

    "KPI Not Met")

 

In the left table this new “KPI Indicator” column was not added and so the table is correct.

In the right table this new column was added and then it is splitting the rows for some of the tickets.

 

indicator.jpg

See this example:

1-14204341391 (in the left the total time is 339.1425 and so it should be indicated as “KPI Not Met” in a unique row). In the right with the new column I have as result two rows with different values for total time and both KPI Met and KPI Not Met.

 

What it seems is this new column when the total time is greater than 60 (KPI reference), it will always break the row in two (one for “met” and another for “not met).

 

 

Could you please help to understand what is wrong and how can I fix this?

 

Thank you!

2 ACCEPTED SOLUTIONS
Fowmy
Super User
Super User

@datanau001 

Because  you added a calculated column, the result is evaluated on each row, to solve it, create a measure as follows and it instead of the column:

KPI Indicator Measure=
IF (
    SUM ( 'V_SR_STATUS_LINES_SEC'[Total Audit Time Hrs] ) < SUM ( 'V_SR_STATUS_LINES_SEC'[SPE KPI] ),
    "KPI Met",
    "KPI Not Met"
)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

Hello, here is a way we can make it works with a calculated column:

KPI Indicator =
CALCULATE (
    SUM ( 'V_SR_STATUS_LINES_SEC'[Total Audit Time Hrs] ),
    FILTER (
        ALLSELECTED ( 'V_SR_STATUS_LINES_SEC' ),
        'V_SR_STATUS_LINES_SEC'[SR] = MAX ( 'V_SR_STATUS_LINES_SEC'[SR] )
    )
)

View solution in original post

3 REPLIES 3
Fowmy
Super User
Super User

@datanau001 

Because  you added a calculated column, the result is evaluated on each row, to solve it, create a measure as follows and it instead of the column:

KPI Indicator Measure=
IF (
    SUM ( 'V_SR_STATUS_LINES_SEC'[Total Audit Time Hrs] ) < SUM ( 'V_SR_STATUS_LINES_SEC'[SPE KPI] ),
    "KPI Met",
    "KPI Not Met"
)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Fowmy Thank you for your reply.

Now with the measure, it worked fine.

However, I'll need this indicator as a column because it will be used to calculate how many tickets were solved as Kpi met and Kpi not met. 

 

Thank you! 

Hello, here is a way we can make it works with a calculated column:

KPI Indicator =
CALCULATE (
    SUM ( 'V_SR_STATUS_LINES_SEC'[Total Audit Time Hrs] ),
    FILTER (
        ALLSELECTED ( 'V_SR_STATUS_LINES_SEC' ),
        'V_SR_STATUS_LINES_SEC'[SR] = MAX ( 'V_SR_STATUS_LINES_SEC'[SR] )
    )
)

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors