Forum Discussion
Formula for below
if (partner_fct= 000001) then show as sold to and if(partner_fct=0000002) then ship to and if (partner_fct=0000055 then sold reference. write powerbi formula
Hi Harish85 ,
Not sure if you want to have a DAX (calculated column or meausre) or a M Language code but should be something similar to this
M Code (Power Query) if [partner_fct] = "000001" then [sold to] else if [partner_fct] = "0000002" then [ship to] else if [partner_fct] = "0000055" then [sold reference] else null DAX Column = SWITCH( Table[partner_fct], "000001". Table[sold to], "000002". Table[ship to], "000005". Table[sold reference])I'm assuming that the coluns are on the same column if you have the columns in different tables then you may need to change the code.
Hi,
You can create a Calculated Column in Microsoft Power BI using SWITCH (cleaner than nested IFs).
Partner Type =
SWITCH(
TRUE(),
TableName[partner_fct] = "000001", "Sold To",
TableName[partner_fct] = "0000002", "Ship To",
TableName[partner_fct] = "0000055", "Sold Reference",
BLANK()
)Replace TableName with your actual table name.
Alternative using IF
Partner Type =
IF(
TableName[partner_fct] = "000001",
"Sold To",
IF(
TableName[partner_fct] = "0000002",
"Ship To",
IF(
TableName[partner_fct] = "0000055",
"Sold Reference",
BLANK()
)
)
)SWITCH(TRUE()) is recommended because it’s easier to maintain if more partner codes are added later.
Hope this helps.
Thanks!
2 Replies
- SamInogicSuper User
Hi,
You can create a Calculated Column in Microsoft Power BI using SWITCH (cleaner than nested IFs).
Partner Type =
SWITCH(
TRUE(),
TableName[partner_fct] = "000001", "Sold To",
TableName[partner_fct] = "0000002", "Ship To",
TableName[partner_fct] = "0000055", "Sold Reference",
BLANK()
)Replace TableName with your actual table name.
Alternative using IF
Partner Type =
IF(
TableName[partner_fct] = "000001",
"Sold To",
IF(
TableName[partner_fct] = "0000002",
"Ship To",
IF(
TableName[partner_fct] = "0000055",
"Sold Reference",
BLANK()
)
)
)SWITCH(TRUE()) is recommended because it’s easier to maintain if more partner codes are added later.
Hope this helps.
Thanks!
- MFelixSuper User
Hi Harish85 ,
Not sure if you want to have a DAX (calculated column or meausre) or a M Language code but should be something similar to this
M Code (Power Query) if [partner_fct] = "000001" then [sold to] else if [partner_fct] = "0000002" then [ship to] else if [partner_fct] = "0000055" then [sold reference] else null DAX Column = SWITCH( Table[partner_fct], "000001". Table[sold to], "000002". Table[ship to], "000005". Table[sold reference])I'm assuming that the coluns are on the same column if you have the columns in different tables then you may need to change the code.