Need help with statement to return a value based a cell containing multiple values

MNik

New Member
Joined
Aug 30, 2022
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I'm new to Power BI and I'm looking for help with a formula for a new column that will return a value based on the contents of a current cell. My data had duplicates for the "Components" column, so I grouped the data in a new column titled "All Status". Now I would like to return a value 1 thru 3 based on the criteria below.

If the cells contains only "To do", I would like it to return a value of 1. It doesn't matter how many times "To Do" is repeated as long as it's the only status in the cell.
If the cell contains any combination of "To Do", "Assigned", "In Progress", "Repeat Validation", "Backlog", "Done Review", or "Done", I would like it to return a value of 2.
If the cell contains only "Done", then I would like the value 3 returned. It doesn't matter how many times "Done" is repeated as long as it's the only status in the cell.

Any suggestions on how I could go about this would be greatly appreciated.

Thanks in advance!
 

Attachments

  • BI Example.png
    BI Example.png
    123.7 KB · Views: 14

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
In Power Query click add a custom column and paste the following as the formula

Power Query:
let lst = List.Distinct(Text.Split([All Status],", ")) in if List.Count(lst)  <> 1 then 2 else Number.Abs(List.PositionOf({"To Do",null,"Done"}, lst{0})) +1)
 
Upvote 0
In Power Query click add a custom column and paste the following as the formula

Power Query:
let lst = List.Distinct(Text.Split([All Status],", ")) in if List.Count(lst)  <> 1 then 2 else Number.Abs(List.PositionOf({"To Do",null,"Done"}, lst{0})) +1)

Thank you for your response. I am getting a Token Eof expected error when pasting the formula into the custom column formula box. I have attached a screenshot for reference.
 

Attachments

  • error.png
    error.png
    20.5 KB · Views: 6
Upvote 0
I pasted from the advanced editor so I shouldn't have included the last parenthesis. Try without the final ")"

Power Query:
let lst = List.Distinct(Text.Split([All Status],", ")) in if List.Count(lst)  <> 1 then 2 else Number.Abs(List.PositionOf({"To Do",null,"Done"}, lst{0})) +1
 
Upvote 0
Solution
I pasted from the advanced editor so I shouldn't have included the last parenthesis. Try without the final ")"

Power Query:
let lst = List.Distinct(Text.Split([All Status],", ")) in if List.Count(lst)  <> 1 then 2 else Number.Abs(List.PositionOf({"To Do",null,"Done"}, lst{0})) +1

It worked perfectly without the extra parenthesis. This saved me a ton of time. Thank you so much for you help!
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top