Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Switch statement in power query

Can some one help me build switch statement in power query
  • Anonymous's avatar
    Anonymous
    5 years ago

    the code you indicate I believe is DAX (which I don't know). Try to see if this is okay for you. If the control conditions are different (not "simple" equalities) it is necessary to change the setting. But in case you should give specific examples of which situation you need to manage.

  • v-jingzhang's avatar
    v-jingzhang
    5 years ago

    Hi Anonymous 

    There is no built-in Switch function in Power Query. In additon to the custom Switch function, you can also achieve this by adding a conditional column easily. It will generate an IF statement like below.

     

    if [Segment1] = 1 then "ABC" else if [Segment1] = 54 then "FGH" else if [Segment1] = 56 then "JKL" else if [Segment1] = 101 then "BNM" else null

     

    Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as the solution to help other members find it.