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
EaglesTony
Post Prodigy
Post Prodigy

How do I get either 0 or a number based on a condition ?

hi,

 

  I have the following table

 

Domain    AppCode      TrainingAssigned

ABC          123                null

DEF           456                Complete

DEF           999                null

DEF           777                In Progress

 

I am trying to find by Domain(group by) the number of AppCodes with TrainingAssigned=Complete, thus I would want something like:

 

Domain    TrainingAssignedTotal

ABC          0

DEF          1

 

 

Thanks

 

1 ACCEPTED SOLUTION

Ok @EaglesTony thanks for clarify.

 

so, can you use this expression and adapt for your case:

let
    // Sample data
    Source = Table.FromRows({
        {"ABC", 123, null},
        {"DEF", 456, "Complete"},
        {"DEF", 999, null},
        {"DEF", 777, "In Progress"}
    }, {"Domain", "AppCode", "TrainingAssigned"}),

    // Group by Domain and count only "Complete"
    Grouped = Table.Group(Source, {"Domain"}, {
        {"TrainingAssignedTotal", 
            each try List.Count(List.Select([TrainingAssigned], (x) => x = "Complete")) otherwise 0, 
            Int64.Type}
    })
in
Grouped

 

Zanqueta_0-1764698544828.png

Zanqueta_1-1764698557021.png

 

If this response was helpful in any way, I’d gladly accept a 👍much like the joy of seeing a DAX measure work first time without needing another FILTER.

Please mark it as the correct solution. It helps other community members find their way faster (and saves them from another endless loop 🌀.

 

 

View solution in original post

3 REPLIES 3
Zanqueta
Solution Supplier
Solution Supplier

Hello @EaglesTony,

 

To achieve this result in Power BI using DAX, you can create a measure that counts only the cases where TrainingAssigned = "Complete" and then use that measure in a visual grouped by Domain.

 
TrainingAssignedTotal =
CALCULATE(
    COUNT    COUNTROWS('YourTable'),
    'YourTable'[TrainingAssigned] = "Complete"

 

If this response was helpful in any way, I’d gladly accept a 👍much like the joy of seeing a DAX measure work first time without needing another FILTER.

Please mark it as the correct solution. It helps other community members find their way faster (and saves them from another endless loop 🌀.

Thanks, but I'd like to do it in PowerQuery, as I want to eventually merge some tables together.

Ok @EaglesTony thanks for clarify.

 

so, can you use this expression and adapt for your case:

let
    // Sample data
    Source = Table.FromRows({
        {"ABC", 123, null},
        {"DEF", 456, "Complete"},
        {"DEF", 999, null},
        {"DEF", 777, "In Progress"}
    }, {"Domain", "AppCode", "TrainingAssigned"}),

    // Group by Domain and count only "Complete"
    Grouped = Table.Group(Source, {"Domain"}, {
        {"TrainingAssignedTotal", 
            each try List.Count(List.Select([TrainingAssigned], (x) => x = "Complete")) otherwise 0, 
            Int64.Type}
    })
in
Grouped

 

Zanqueta_0-1764698544828.png

Zanqueta_1-1764698557021.png

 

If this response was helpful in any way, I’d gladly accept a 👍much like the joy of seeing a DAX measure work first time without needing another FILTER.

Please mark it as the correct solution. It helps other community members find their way faster (and saves them from another endless loop 🌀.

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.