Forum Discussion
Dax help needed
- 1 year ago
Why DAX? This can be done in Power Query too.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUfJMSU0syczPAzJBKFYnWikJyHBLTSzOTMrMySypBPIMLWByyUCGa0VqcilUj4UhTCYFyHDOyS9OzS8tATLNYOKpIPH83IKc1JJUiCWGJkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [S.No = _t, Phase = _t, Count = _t, Count1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Count", Int64.Type}, {"Count1", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Count2PQ", (k)=> List.Sum(Table.AddColumn(Table.SelectRows(#"Changed Type", each [S.No]>k[S.No]),"l",each [Count]??0+[Count1]??0)[l]),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". Once you examined the code, replace the entire Source step with your own source.
Here is the DAX version:
Naveen29 , Try using
Count2 =
VAR CurrentPhase = SELECTEDVALUE('Table'[Phase])
RETURN
SWITCH(
TRUE(),
CurrentPhase = "Ideation",
CALCULATE(SUM('Table'[Count])),
CurrentPhase = "Feasibility",
CALCULATE(SUM('Table'[Count]), 'Table'[Phase] IN {"Feasibility", "Execution", "Closeout"}),
CurrentPhase = "Execution",
CALCULATE(SUM('Table'[Count]), 'Table'[Phase] IN {"Execution", "Closeout"}),
CurrentPhase = "Closeout",
CALCULATE(SUM('Table'[Count]), 'Table'[Phase] = "Closeout")
)