Forum Discussion
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 = 'CLASS' // issue is here in this line splits boolean as True and False iam expecting this to display as 'N' (combination of both the booleans true and false )
ELSE
v_FLAG END
Output Obatined is:
Expected output:
null
N (combination of both true and false)
Y
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 ENDBest Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
1 Reply
- v-jingzhangCommunity Support
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 ENDBest Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.