Forum Discussion
To add a column in Power BI using if - else functions
- Anonymous2 years ago
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
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.
- Anonymous2 years agoNot 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
- Sushant__082 years agoRegular Visitor
Thank you so much Anonymous . It worked perfectly.