Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Naveen29
Helper II
Helper II

Dax help needed

I would like to create a DAX which ideally sum the values as per below. The new measure should be something should dynamically display the values. Here is the example of the data

Count for each phase

count 1 is the measure that only shows complete phase

count2 is new measure 

New measure should be the logic behind the count2

Naveen29_0-1740840000804.png

 

 

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Why DAX?  This can be done in Power Query too.

 

lbendlin_0-1740849019791.png

 

 

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:

 

lbendlin_1-1740849290739.png

 

View solution in original post

5 REPLIES 5
v-prasare
Community Support
Community Support

Hi @Naveen29,

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for your issue worked? or let us know if you need any further assistance here?

 

 

 

 

Thanks,

Prashanth Are

MS Fabric community support

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query

v-prasare
Community Support
Community Support

Hi @Naveen29,

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for your issue worked? or let us know if you need any further assistance here?

 

 

 

 

Thanks,

Prashanth Are

MS Fabric community support

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query

v-prasare
Community Support
Community Support

Hi @Naveen29As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for your issue worked? or let us know if you need any further assistance here?

 

@lbendlin & @bhanu_gautam , Thanks for your promt response

 

 

Thanks,

Prashanth Are

MS Fabric community support

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query

lbendlin
Super User
Super User

Why DAX?  This can be done in Power Query too.

 

lbendlin_0-1740849019791.png

 

 

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:

 

lbendlin_1-1740849290739.png

 

bhanu_gautam
Super User
Super User

@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")
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.