Forum Discussion
TypingQuery
1 year agoFrequent Visitor
Creating new table with distinct rows from single column with multiple value types
Good day! I am trying to do a few things with a table in order to filter by values in a single column, and also to calculate scores for the whole. I have a table from a form with a unique Acc...
Anonymous
1 year agoNot applicable
HIi TypingQuery ,
I created a sample pbix file(see the attachment), please check if that is what you want.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjI0MjZR0lEyMjI0tQTSGo4Kfom5qZpKsTookmYGEEmXxBIskoZAOrikKDMvHUPKCEhXphbr5+XrJ+Uk5mVjKDDGpcAUn7NM8TnLFLezTAk5yxSns2IB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Account ID" = _t, #"Question ID" = _t, Response = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Account ID", Int64.Type}, {"Question ID", Int64.Type}, {"Response", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Account ID"}, {{"Index", each Table.AddIndexColumn(_, "Index",1,1), type table}}),
#"Expanded Index" = Table.ExpandTableColumn(#"Grouped Rows", "Index", {"Question ID", "Response", "Index"}, {"Question ID", "Response", "Index"}),
#"Added Custom" = Table.AddColumn(#"Expanded Index", "Score", each try #"Points Table"[Score]{List.PositionOf(#"Points Table"[Question ID],[Question ID])} otherwise null),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom", each if [Index]>2 then [Score] else [Response]),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "Type", each if [Index]=1 then "Name" else if [Index]=2 then "Date" else "Score"),
#"Removed Columns1" = Table.RemoveColumns(#"Added Custom2",{"Question ID", "Response", "Index", "Score"}),
#"Grouped Rows1" = Table.Group(#"Removed Columns1", {"Account ID", "Type"}, {{"Data", each try List.Sum([Custom]) otherwise [Custom]{0} }}),
#"Pivoted Column" = Table.Pivot(#"Grouped Rows1", List.Distinct(#"Grouped Rows1"[Type]), "Type", "Data")
in
#"Pivoted Column"
Best Regards
- TypingQuery1 year agoFrequent Visitor
Thank you for the awesome guidance!! I will give this a try and see how I end up.
*Edit* Unfortunately I couldn't get this to work with my data and kept receiving token syntax errors. Likely due to my limited understanding off the transformation steps converting it.- Anonymous1 year agoNot applicable
Hi TypingQuery ,
Could you please share the codes with the syntax error in your Advanced Editor? Later we can review it and give you a suitable solution. Thank you.
Best Regards