Forum Discussion

Dinvae's avatar
Dinvae
Regular Visitor
3 years ago
Solved

Split Boolean Issue to display as only 'N' Flag value

Hi Experts,   Assume v_Flag is the filter/slicer which has values like Y, N, Null, in Query editor iam placing below code: case when v_FLAG = 'Y' THEN v_FLAG when v_FLAG = 'N' THEN REL_TYPE = ...
  • v-jingzhang's avatar
    3 years ago

    Hi Dinvae 

     

    Power Query doesn't have case statement. You can use if ... then ... else ..., please refer to M Language Conditionals - PowerQuery M

     

    In your case, if v_FLAG is a column, you can add a custom column with this M code:

    if [v_FLAG] = "Y" then [v_FLAG] else if [v_FLAG] = "N" then "N" else [v_FLAG]

    or

    if [v_FLAG] = "N" then "N" else [v_FLAG]

     

    If you are not using Power Query, you just need to modify your current code into

    case
    when v_FLAG = 'Y' THEN
    v_FLAG
    when v_FLAG = 'N' THEN
    'N'  
    ELSE
    v_FLAG END

     

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