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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Kudoed Authors