Forum Discussion
Is there any other way to do a If Statement? or Simplify the code
- 6 years ago
Hi Anonymous
Its not a Power Query, its a DAX question, as I see
Anyway, try Switch function https://docs.microsoft.com/en-us/dax/switch-function-dax like
Sub Group Seq Date = SWITCH( DRIVE_In_Scope_Unit_List[Sub Group Sequence E2E] ; "1";"12/01/2018"; "2";"02/01/2019"; "3";"03/01/2019"; "Unknown number" )do not hesitate to give a kudo to useful posts and mark solutions as solution
- Anonymous6 years ago
Thank you az38. You code is almost right need to replace ";" to "," and then i can run it.
Sub Group Seq Date = SWITCH ( DRIVE_In_Scope_Unit_List[Sub Group Sequence E2E], "1", "12/01/2018", "2", "02/01/2019", "3", "03/01/2019", "4", "03/01/2019", "5", "04/01/2019", "6", "04/01/2019", "7", "05/01/2019", "8", "06/01/2019", "9", "06/01/2019", "10", "07/01/2019", "11", "07/01/2019", "12", "07/01/2019", "13", "08/01/2019", "14", "08/01/2019", "15", "08/01/2019", "16", "09/01/2019", "17", "09/01/2019", "18", "09/01/2019", "19", "09/01/2019", "20", "09/01/2019", "21", "10/01/2019", "22", "10/01/2019", "999", "10/01/2019", "11/01/2019" )
Hi Anonymous
Its not a Power Query, its a DAX question, as I see
Anyway, try Switch function https://docs.microsoft.com/en-us/dax/switch-function-dax like
Sub Group Seq Date =
SWITCH(
DRIVE_In_Scope_Unit_List[Sub Group Sequence E2E] ;
"1";"12/01/2018";
"2";"02/01/2019";
"3";"03/01/2019";
"Unknown number"
)
do not hesitate to give a kudo to useful posts and mark solutions as solution
Thank you az38. You code is almost right need to replace ";" to "," and then i can run it.
Sub Group Seq Date =
SWITCH (
DRIVE_In_Scope_Unit_List[Sub Group Sequence E2E],
"1", "12/01/2018",
"2", "02/01/2019",
"3", "03/01/2019",
"4", "03/01/2019",
"5", "04/01/2019",
"6", "04/01/2019",
"7", "05/01/2019",
"8", "06/01/2019",
"9", "06/01/2019",
"10", "07/01/2019",
"11", "07/01/2019",
"12", "07/01/2019",
"13", "08/01/2019",
"14", "08/01/2019",
"15", "08/01/2019",
"16", "09/01/2019",
"17", "09/01/2019",
"18", "09/01/2019",
"19", "09/01/2019",
"20", "09/01/2019",
"21", "10/01/2019",
"22", "10/01/2019",
"999", "10/01/2019",
"11/01/2019"
)
- az386 years ago
Community Champion
Anonymous
the correct symbol ";" or ",' is depends on system localization.
Good luck!
do not hesitate to give a kudo to useful posts and mark solutions as solution