Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
jomask
Frequent Visitor

separate values into columns

Hello community, I'm a new user of Power BI and would like to know how to move values from  from StateofProcessing column to additional columns that will contain only , closed, stand, none, enhanced values, see pictures, Please kindly help me. Thank you.

The link contains files excel, power bi file and picture, if you can pls respond with a picture.

https://easyupload.io/zoci4s 

 

regards,

 

Joma

 

 

result.pngScreenshot 2024-09-21 215026.png

2 ACCEPTED SOLUTIONS

Like this? Pbix file attached.

 

dufoq3_0-1726999119204.png

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

Hi, if you have space in Promoted Headers, you have to use #"Promoted Headers" as reference so replace Values step with this:

= List.Buffer(List.Sort(List.Distinct(#"Promoted Headers"[StateOfProceedingID])))

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

13 REPLIES 13
dufoq3
Super User
Super User

Could you explain it in detail please? I don't understand why do you need that. There is no "open" value in [StateOfProceedingID] column.

 

dufoq3_0-1726996298614.png

 

If you want to add new column for each row with values from [StateOfProceedingID] column do this:

 

let
    Source = Excel.Workbook(File.Contents("C:\Downloads\PowerQueryForum\jomask\Book1.xlsx"), true, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    States = List.Distinct(Sheet1_Sheet[StateOfProceedingID]),
    StepBack = Sheet1_Sheet,
    Ad_CaseColumns = List.Accumulate(
        {0..List.Count(States)-1},
        StepBack,
        (s,c)=> Table.AddColumn(s, "Case " & Text.From(c+1), (x)=> States{c}, type text))
in
    Ad_CaseColumns

 

 

If you want add 5 columns with values None, Closed, Enchanced, Open, Pending - use this:

 

let
    Source = Excel.Workbook(File.Contents("C:\Downloads\PowerQueryForum\jomask\Book1.xlsx"), true, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    Ad_CaseColumns = [ values = {"None", "Closed", "Enchanced", "Open", "Pending"},
    la =  List.Accumulate(
                List.Zip({ {0..List.Count(values)-1}, values }),
                Sheet1_Sheet,
                (s,c)=> Table.AddColumn(s, "Case " & Text.From(c{0}+1), (x)=> c{1}, type text))
  ][la]
in
    Ad_CaseColumns

 

 

Don't forget to replace address to your excel file.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

jomask
Frequent Visitor

I would like to use this code above for this query as I dont use Excel sheets but SQL tables, please can you help me with this. I try to fidle around how to change source  and fit in your code but it makes errors...

jomask_0-1727250200539.png

The Result would be like this 

jomask_1-1727251627498.png

 

 

jomask
Frequent Visitor

Hello Thank you for a response. I know there is no "open" just quickly created a sample and snipped a picture. I would like those "values"(I turned them into the non-digital text, originally they are digital 1,2,3,4 each number belongs to Closed, enhanced...) Closed, enhanced, none, stand put the next each other in columns in Power BI with a Column names "case 1", "case 2", "case 3" and "case 4". The picture in Excel ( only for explanation my idea) with the red arrow is what I need in Power Bi.

Like this? Pbix file attached.

 

dufoq3_0-1726999119204.png

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

jomask
Frequent Visitor

Hello, one more question , I would liked to do a Pie chart from the Case column. It would show(count) Case1,Case2,Case3,Case4,Case5. How can I do that? Once again Thank you

jomask
Frequent Visitor

Thank you

You're welcome.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

jomask
Frequent Visitor

17270829870866852911831389437612.jpg

Hello,

When I add the step "Values" it says "expression error:the name 'PromoteHeaders' wasn't recognised. Make sure you spelled correctly..... but my step before is "Promoted Headers"... How did you make step *Values"?

Hi, if you have space in Promoted Headers, you have to use #"Promoted Headers" as reference so replace Values step with this:

= List.Buffer(List.Sort(List.Distinct(#"Promoted Headers"[StateOfProceedingID])))

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

jomask
Frequent Visitor

Thank you it works 🙂

jomask
Frequent Visitor

Yes that's the one

Hi @jomask ,

If @dufoq3 's solution works for you, please accept the reply as Solution so that more users facing the same problem can find it faster. Thank you!

Best Regards,
Dino Tao

lbendlin
Super User
Super User

Resist the urge to do that.  It is not necessary.  Ingest your data as is and let the visuals do the pivoting work for you.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.