Forum Discussion
AO1
2 years agoFrequent Visitor
New Column or New Measure
Hi, I'm new to PowerBi and would really appreciate your help with creating either a new column or new measure. So i have the below table: Parameter Treatment Score A TRT1 10 A C...
- 2 years ago
This doesn 't seem to need a measure. Even a calculated column is overkill. Much simpler to do in Power Query.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZcwxDoAgDIXhuzAz0FJURmXXxLAR7n8NS0mgxIUmXx5/KeY01uQ3Ax9wptou6bn5xTiAJ9gmi3g+O2ohPh5ErhlGN6SHIegJ/j61MC3SwuBF0gwHGtLDtOmJhKOWFsZDi4T5V/0A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Parameter = _t, Treatment = _t, Score = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Parameter", type text}, {"Treatment", type text}, {"Score", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "New_Column", (k)=> Table.SelectRows(#"Changed Type",each [Parameter]=k[Parameter] and [Treatment]="CON")[Score]{0},Int64.Type) in #"Added Custom"How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
lbendlin
2 years agoSuper User
This doesn 't seem to need a measure. Even a calculated column is overkill. Much simpler to do in Power Query.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZcwxDoAgDIXhuzAz0FJURmXXxLAR7n8NS0mgxIUmXx5/KeY01uQ3Ax9wptou6bn5xTiAJ9gmi3g+O2ohPh5ErhlGN6SHIegJ/j61MC3SwuBF0gwHGtLDtOmJhKOWFsZDi4T5V/0A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Parameter = _t, Treatment = _t, Score = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Parameter", type text}, {"Treatment", type text}, {"Score", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "New_Column", (k)=> Table.SelectRows(#"Changed Type",each [Parameter]=k[Parameter] and [Treatment]="CON")[Score]{0},Int64.Type)
in
#"Added Custom"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".