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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Aidanok
New Member

Calculate totals of matching values in different columns

I'm newer to PowerBi and this is probably an easy solve for lots of people but I can't figure it out. I want to get the total times a value is present in a table when that value is in present in multiple colunms. 

 

Top table is example of table structure and bottom table is desired outcome.

 

Thank you in advance!

Aidanok_0-1709934799097.png

 

Desired outcome

Aidanok_1-1709934856837.png

1 ACCEPTED SOLUTION
v-weiyan1-msft
Community Support
Community Support

Hi @Aidanok ,

 

@wini_R nice method! Thank you, for your quick response and the solution provided.
And based on the sample and description you provided, you can also consider the following method.
1.Please try code as below to create Calculated table.

Table = 
DISTINCT ( SELECTCOLUMNS ( 'Projectdetails', "Name", 'Projectdetails'[Lead] ) )

vweiyan1msft_0-1710135890280.png

2.Then use the following code to create a Calculated column.

Total projects assocated = 
VAR _Name = 'Table'[Name]
RETURN
    CALCULATE (
        COUNTROWS ( 'Projectdetails' ),
        FILTER (
            'Projectdetails',
            'Projectdetails'[Lead] = _Name
                || 'Projectdetails'[Support] = _Name
        )
    )

Result is as below.

vweiyan1msft_1-1710135968510.png


Best Regards,
Yulia Yan


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-weiyan1-msft
Community Support
Community Support

Hi @Aidanok ,

 

@wini_R nice method! Thank you, for your quick response and the solution provided.
And based on the sample and description you provided, you can also consider the following method.
1.Please try code as below to create Calculated table.

Table = 
DISTINCT ( SELECTCOLUMNS ( 'Projectdetails', "Name", 'Projectdetails'[Lead] ) )

vweiyan1msft_0-1710135890280.png

2.Then use the following code to create a Calculated column.

Total projects assocated = 
VAR _Name = 'Table'[Name]
RETURN
    CALCULATE (
        COUNTROWS ( 'Projectdetails' ),
        FILTER (
            'Projectdetails',
            'Projectdetails'[Lead] = _Name
                || 'Projectdetails'[Support] = _Name
        )
    )

Result is as below.

vweiyan1msft_1-1710135968510.png


Best Regards,
Yulia Yan


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for your response. This worked perfectly!!!

wini_R
Solution Supplier
Solution Supplier

Hi @Aidanok,
I would transform the source table in power query to get the expected result. Here is example query (you can paste it in advance editor):

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfJKzEsFUkqxOtFKRkCGY14eTBQkZAzkOKWChHwTi7LBQiZwITDXFCYH5Zsh+CCzQELmcHNB+kAiFnARMNcSzSGGBkBWcGIu3CWxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Lead = _t, Support = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"ID"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Value] <> "")),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Value"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
    #"Grouped Rows"

 

And that's the outome:

wini_R_0-1709937499867.png

 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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 Solution Authors