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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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