Forum Discussion
How to perform a function only for a unique value from a column
- 4 years ago
You could add an index column that restarts with each new NUMBER, and then add a new column with your formula conditional on the index.
See Create Row Number for Each Group in Power BI using Power Query - RADACAD.
Steps would include grouping by NUMBER, keeping all rows, adding an index column, then expanding.
Then you could just add your column with the Custom Formula option in the UI.
- 4 years ago
Hi,
i was working on the same schema as karen578
this is the transformations in power query
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNlHSUTIw0TMw1zMyAjINDeFMXTOlWB3i1BgAAZoaBFPXEqzGEghQ1RhYINSYUk9NLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [NUMBER = _t, PLANNEDDATE = _t, REALDATE = _t, BACKLOG = _t]),
#"Grouped Rows" = Table.Group(Source, {"NUMBER"}, {{"AllRows", each _, type table [NUMBER=nullable text, PLANNEDDATE=nullable text, REALDATE=nullable text, BACKLOG=nullable text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([AllRows],"Index",1,1)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"NUMBER", "PLANNEDDATE", "REALDATE", "BACKLOG", "Index"}, {"NUMBER", "PLANNEDDATE", "REALDATE", "BACKLOG", "Index"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Custom",{{"NUMBER", type text}, {"PLANNEDDATE", type date}, {"REALDATE", type date}, {"BACKLOG", Int64.Type}, {"Index", Int64.Type}})
in
#"Changed Type"and finally the dax
Column =if('Table'[Index]=1, 'Table'[BACKLOG])If this post is useful to help you to solve your issue, consider giving the post a thumbs up and accepting it as a solution !
You could add an index column that restarts with each new NUMBER, and then add a new column with your formula conditional on the index.
See Create Row Number for Each Group in Power BI using Power Query - RADACAD.
Steps would include grouping by NUMBER, keeping all rows, adding an index column, then expanding.
Then you could just add your column with the Custom Formula option in the UI.