Forum Discussion
rob_vander2
Helper II
1 year agocreate flag using complex if condition in power query
Hi All, I have below dataset and required output in screenshot. I would like to create Flag column in power query with below conditions if Count is blank, all rows should be flagged as 1 if Co...
- 1 year ago
Hi rob_vander2 ,You could achive this by custom column and if condition please try these
- Add a Custom Column:
- Go to the "Add Column" tab and select "Custom Column."
- Formula:
if [Count] = null then 1
else if [Count] = 1 and ([Ref] = 11 or [Ref] = 21 or [Ref] = 3) then 1
else if [Count] = 2 and [Type] = "B" then 1
else null
Filter the Rows:
- After adding the Flag column, filter out rows where the Flag is null if you only want flagged rows in the final output.
If this post helped please do give a kudos and accept this as a solution
Thanks In Advance
- After adding the Flag column, filter out rows where the Flag is null if you only want flagged rows in the final output.
- Add a Custom Column:
- 1 year ago
Hi rob_vander2 , here's a solution you can check out. I'll attach a snippet of M code I used. Thanks
Akash_Varuna
Super User
1 year agoHi rob_vander2 ,You could achive this by custom column and if condition please try these
- Add a Custom Column:
- Go to the "Add Column" tab and select "Custom Column."
- Formula:
if [Count] = null then 1
else if [Count] = 1 and ([Ref] = 11 or [Ref] = 21 or [Ref] = 3) then 1
else if [Count] = 2 and [Type] = "B" then 1
else null
Filter the Rows:
- After adding the Flag column, filter out rows where the Flag is null if you only want flagged rows in the final output.
If this post helped please do give a kudos and accept this as a solution
Thanks In Advance
- After adding the Flag column, filter out rows where the Flag is null if you only want flagged rows in the final output.