Forum Discussion
separate values into columns
- 1 year ago
Like this? Pbix file attached.
- 1 year ago
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])))
Could you explain it in detail please? I don't understand why do you need that. There is no "open" value in [StateOfProceedingID] column.
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.
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...
The Result would be like this