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
lja
New Member

Count occurrences across 2 columns and able to filter

Hi all,

 

I'm after some guidance please.

 

In power BI I have a data table as below and trying to summarise it

as an example the data looks like this

lja_1-1642427916985.png

 

 

I'm trying to populate a table which looks at the name accross primary and seconday and counts how may time it occures in the year and totals it.

lja_0-1642427901986.png

Could anyone provide some guidance on how to do this please?

 

8 REPLIES 8
lja
New Member

Thanks you.

 

could you confirm what the below [primary] relates to please?

 

[Primary]

@lja  it relates to the column name is the slicer table.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

I get this error message?

A table of multiple values was supplied where a single value was expected.

@lja  please follow the pbix attached

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Don't worry, the pbix didn't help explain it. I need someone to explain rather than send the file as this sits within a larger report.

 

Thanks for you time

smpa01
Super User
Super User

@lja  What is the exact end result desired?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

HI, 

This is the result i'd like:

 

lja_0-1642428913403.png

 

@lja  firstly you need to build a slicer table like this

Slicer =
FILTER (
    DISTINCT (
        UNION ( VALUES ( 'Table'[Primary] ), VALUES ( 'Table'[Secondary] ) )
    ),
    [Primary] <> BLANK ()
)

 

and then you can use a measure like this

Measure =
VAR _primary =
    CALCULATE (
        COUNT ( 'Table'[Year] ),
        TREATAS ( VALUES ( Slicer[Primary] ), 'Table'[Primary] )
    )
VAR _secondary =
    CALCULATE (
        COUNT ( 'Table'[Year] ),
        TREATAS ( VALUES ( Slicer[Primary] ), 'Table'[Secondary] )
    )
RETURN
    _primary + _secondary

 

which gives you this

smpa01_0-1642429600393.png

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

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.

Top Solution Authors
Top Kudoed Authors