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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Sushant__08
Regular Visitor

To add a column in Power BI using if - else functions

Dear All,

 

I am new to Power BI and was having issues in creating a new column.

 

Present table in Power BI is as below:

 

Sushant__08_0-1721369327128.png

 

And I want to a new column named "EAC BQ" at the end as per the following rule.

 

Sushant__08_1-1721369733547.png

 

If EACBQ Flag column has inputs ("Model" or "Forecast"), then EAC BQ column data will reflect to the column "Model BQ" and "Forecast BQ" respectively.

 

But if EACBQ Flag column is empty, then, EAC BQ will reflect to the BQs as per the status indicated. ( In case of above screenshot, only FR issued is seen. )

 

Could you please help to create a formula to accomodate the rule ?

 

Thanks in advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

To accommodate the updated requirements, here’s the revised DAX formula. This formula checks both if the ‘EACBQFlag’ column is not blank and contains either "Model" or "Forecast" and assigns the respective BQ column value directly. If the ‘EACBQFlag’ column is blank, it uses the ‘status’ column to determine the value:

 

NewColumn =

SWITCH(

    TRUE(),

    'YourTable'[EACBQFlag] = "Model", 'YourTable'[Model BQ],

    'YourTable'[EACBQFlag] = "Forecast", 'YourTable'[Forecast BQ],

    ISBLANK('YourTable'[EACBQFlag]) && 'YourTable'[status] = "Before Design Start", 'YourTable'[Target BQ],

    ISBLANK('YourTable'[EACBQFlag]) && 'YourTable'[status] = "Design Started", 'YourTable'[Forecast BQ],

    ISBLANK('YourTable'[EACBQFlag]) && 'YourTable'[status] = "FR Issued", 'YourTable'[Model BQ],

    ISBLANK('YourTable'[EACBQFlag]) && 'YourTable'[status] = "FC Issued", 'YourTable'[Model BQ],

    BLANK()

)

Regards,

Chiranjeevi Kudupudi

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @Sushant__08 ,

 

Thanks for your help, @rajendraongole1 .

Her's the calculated column with DAX:

 

EAC BQ = SWITCH([EACBQFlag],"",[Status],"Model","Model BQ","Forecast","Forecast BQ")

 

vstephenmsft_0-1721614674915.png

Or:

 

EAC BQ 2 = IF([EACBQFlag]=BLANK(),[Status],IF([EACBQFlag]="Model","Model BQ",IF([EACBQFlag]="Forecast","Forecast BQ")))

 

vstephenmsft_1-1721614741330.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you @Anonymous ,

 

But I was to assign numerical values in the new column "EAC BQ" from the available BQ data.

 

Like,

 

If "EACBQ flag" is blank, then my intention is to select a BQ data based on the status update. Like,

 

Status = Before Design Start ; Data = number / data in "Target BQ" column

 

Status = "Design Started" ; Data = Number in "Forecast BQ" column

 

Status = "FR Issued" ; Data = Number in "Model BQ" column

 

Status = "FC Issued" ; Data = Number in "Model BQ" column

 

But if EACBQ Flag column is not empty. If EACBQ Flag = "Model" then "EAC BQ" = number in "Model BQ" column.

 

Similarly,

 

If EACBQ Flag = "Forecast", then EAC BQ = Number in "Forecast BQ" column.

 

It is a bit confusing but could you please help me. I am stuck in this report from last few days.

 

Thanks so much for your attention.

rajendraongole1
Super User
Super User

Hi @Sushant__08 - create the new column EAC BQ based on the specified rules, you can use a combination of conditional logic in DAX.

Create calculated column as below:

 

EAC BQ =
VAR EACFlag = [EACBQ Flag]
RETURN
SWITCH(
TRUE(),
EACFlag = "Model", [Model BQ],
EACFlag = "Forecast", [Forecast BQ],
ISBLANK(EACFlag) && NOT(ISBLANK([FR issued])), [FR issued],
BLANK()
)

 

Hope it helps

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thank you for your reply.

 

But can we create a logic in DAX accomodating all conditions in status column ?

 

For instance,

In case of a blank EACBQFlag column, For status value,

 

Before Design Start ---- > To use column "Target BQ"

Design Started ---- > Forecast BQ

FR Issued ---- > Model BQ

FC Issued ---- > Model BQ

 

For now, only FR issued has been considered.

 

Thank you.

Anonymous
Not applicable

Hi Sushant,

 

The below calculation might meet your requirements.

NewColumn =

SWITCH(

    TRUE(),

    ISBLANK('YourTable'[EACBQFlag]) && 'YourTable'[status] = "Before Design Start", 'YourTable'[Target BQ],

    ISBLANK('YourTable'[EACBQFlag]) && 'YourTable'[status] = "Design Started", 'YourTable'[Forecast BQ],

    ISBLANK('YourTable'[EACBQFlag]) && 'YourTable'[status] = "FR Issued", 'YourTable'[Model BQ],

    ISBLANK('YourTable'[EACBQFlag]) && 'YourTable'[status] = "FC Issued", 'YourTable'[Model BQ],

    BLANK()

)


Regards,

Chiranjeevi Kudupudi

Thank you @Anonymous sir,

 

The solution is almost okay.

 

But if "EACBQ Flag" column = "Model" or "Forecast", then we can directly refer to "Model BQ" and "Forecast BQ" columns.

 

And status info is not required to be considered.

 

Could you please assist in updating the code to include a scenerio that EACBQ Flag column in not blank. As, it could have either "Model" or "Forecast" as well.

Anonymous
Not applicable

To accommodate the updated requirements, here’s the revised DAX formula. This formula checks both if the ‘EACBQFlag’ column is not blank and contains either "Model" or "Forecast" and assigns the respective BQ column value directly. If the ‘EACBQFlag’ column is blank, it uses the ‘status’ column to determine the value:

 

NewColumn =

SWITCH(

    TRUE(),

    'YourTable'[EACBQFlag] = "Model", 'YourTable'[Model BQ],

    'YourTable'[EACBQFlag] = "Forecast", 'YourTable'[Forecast BQ],

    ISBLANK('YourTable'[EACBQFlag]) && 'YourTable'[status] = "Before Design Start", 'YourTable'[Target BQ],

    ISBLANK('YourTable'[EACBQFlag]) && 'YourTable'[status] = "Design Started", 'YourTable'[Forecast BQ],

    ISBLANK('YourTable'[EACBQFlag]) && 'YourTable'[status] = "FR Issued", 'YourTable'[Model BQ],

    ISBLANK('YourTable'[EACBQFlag]) && 'YourTable'[status] = "FC Issued", 'YourTable'[Model BQ],

    BLANK()

)

Regards,

Chiranjeevi Kudupudi

Thank you so much @Anonymous . It worked perfectly.

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 community update carousel

Fabric Community Update - June 2025

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