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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Jit007
Helper II
Helper II

Need help with SUM calculation based on filter

Agent IDRequest#Parameter Q1Score
AARI001Yes15
AARI002Yes15
BBRI003No0
BBRI004No0

 

Total Checked Total YesTotal   NoAchieved %
42250%

 

I trying to get the Achieved result using calculate(SUM + Filter calculation but its not working- not sure whether i am going correctly to get that result. Please direct me to correct solution. I am new to DAX & still learning. Thanks

Here I need to calculate Total Yes divide by Total Checked 

 

2 ACCEPTED SOLUTIONS
dufoq3
Super User
Super User

Hi @Jit007,

 

Result:

dufoq3_0-1712082213721.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRU0lEK8jQwMATSkanFQNLQVClWB0nGCF3GyQkqYwyk/fKBhAGquAmSeCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Agent ID" = _t, #"Request#" = _t, #"Parameter Q1" = _t, Score = _t]),
    Ad_GroupHelper = Table.AddColumn(Source, "GoupHelper", each 1, Int64.Type),
    GroupedRows = Table.Group(Ad_GroupHelper, {"GoupHelper"}, {
        {"Total Checked", each Table.RowCount(_), Int64.Type},
        {"Total Yes", each Table.RowCount(Table.SelectRows(_, (x)=> x[Parameter Q1] = "Yes")), Int64.Type},
        {"Total No", each Table.RowCount(Table.SelectRows(_, (x)=> x[Parameter Q1] = "No")), Int64.Type} }),
    Ad_Achieved = Table.AddColumn(GroupedRows, "Achieved %", each [Total Yes] / [Total Checked], Percentage.Type),
    RemovedColumns = Table.RemoveColumns(Ad_Achieved,{"GoupHelper"})
in
    RemovedColumns

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

gmsamborn
Super User
Super User

Hi @Jit007 

 

My solution is in DAX.

 

The measures are as follows:

 

Total Checked = 
    CALCULATE(
        COUNTROWS( 'Table' ),
        ALL( 'Table' )
    )

Total Yes = 
    CALCULATE(
        COUNTROWS( 'Table' ),
        'Table'[Parameter Q1] = "Yes"
    )

Total No = 
    CALCULATE(
        COUNTROWS( 'Table' ),
        'Table'[Parameter Q1] = "No"
    )

Achieved % = 
    DIVIDE(
        [Total Yes],
        [Total Checked]
    )

 

 

Let me know if you have any questions.

 

Jit007.pbix

 



Proud to be a Super User!

daxformatter.com makes life EASIER!

View solution in original post

2 REPLIES 2
gmsamborn
Super User
Super User

Hi @Jit007 

 

My solution is in DAX.

 

The measures are as follows:

 

Total Checked = 
    CALCULATE(
        COUNTROWS( 'Table' ),
        ALL( 'Table' )
    )

Total Yes = 
    CALCULATE(
        COUNTROWS( 'Table' ),
        'Table'[Parameter Q1] = "Yes"
    )

Total No = 
    CALCULATE(
        COUNTROWS( 'Table' ),
        'Table'[Parameter Q1] = "No"
    )

Achieved % = 
    DIVIDE(
        [Total Yes],
        [Total Checked]
    )

 

 

Let me know if you have any questions.

 

Jit007.pbix

 



Proud to be a Super User!

daxformatter.com makes life EASIER!
dufoq3
Super User
Super User

Hi @Jit007,

 

Result:

dufoq3_0-1712082213721.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRU0lEK8jQwMATSkanFQNLQVClWB0nGCF3GyQkqYwyk/fKBhAGquAmSeCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Agent ID" = _t, #"Request#" = _t, #"Parameter Q1" = _t, Score = _t]),
    Ad_GroupHelper = Table.AddColumn(Source, "GoupHelper", each 1, Int64.Type),
    GroupedRows = Table.Group(Ad_GroupHelper, {"GoupHelper"}, {
        {"Total Checked", each Table.RowCount(_), Int64.Type},
        {"Total Yes", each Table.RowCount(Table.SelectRows(_, (x)=> x[Parameter Q1] = "Yes")), Int64.Type},
        {"Total No", each Table.RowCount(Table.SelectRows(_, (x)=> x[Parameter Q1] = "No")), Int64.Type} }),
    Ad_Achieved = Table.AddColumn(GroupedRows, "Achieved %", each [Total Yes] / [Total Checked], Percentage.Type),
    RemovedColumns = Table.RemoveColumns(Ad_Achieved,{"GoupHelper"})
in
    RemovedColumns

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors