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
SAPpowerbi
Helper II
Helper II

Count values in another table

Hello Team ,

 

I have a below matrix table in my dashboard .Based on that I want show data in another table

 

Below is matrix table

 

----Client Name   , Service line and revenue is main KPI .

 

Service Line

IT

HR

Law

Clint name

 

 

 

ABC

50

40

30

XYZ

40

 

 

SAN

20

 

 

MMM

10

10

20

 

explanation - In above table we can see Clint name – ABC and MMM , Revenue value present for All the (IT ,HR ,Law ) 3  service line – So we need to put this into below output -Revenue in 3 service line and count is = 2  

(Ref - Because revenue is present in all the 3 service line thus the reason we take this in revenue in 3 service line  )

 

--Same for Clint XYZ and SAN is present in 1 service line like IT – so we need to put this into below Revenue in 1 service line and count is = 2

 

We take count as 1 for each client based on above logic .

 

Expected output -below table

 

 

Service line 1/2/3

Count based on service line

Revenue in 1 Service line

2

Revenue in 2 Service line

0

Revenue in 3 Service line

2

 

Thank you .

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @SAPpowerbi ,

 

Here's my solutions.

Sample data:

vstephenmsft_0-1652083759621.png

 

1.Create a count measure to count the service line.

Count = CALCULATE(COUNT('Table'[Service Line]),ALLEXCEPT('Table','Table'[Clint name]))

2.Create another three measures to count three situations.

Revenue in 1 Service line = CALCULATE(DISTINCTCOUNT('Table'[Clint name]),FILTER('Table',[Count]=1))+0
Revenue in 2 Service line = CALCULATE(DISTINCTCOUNT('Table'[Clint name]),FILTER('Table',[Count]=2))+0
Revenue in 3 Service line = CALCULATE(DISTINCTCOUNT('Table'[Clint name]),FILTER('Table',[Count]=3))+0

3.Put three measures into a matrix visual, and then switch values to rows.

vstephenmsft_1-1652084164298.png

 

Another solution:

1.Create a table by entering data.

vstephenmsft_2-1652084223256.png

2.Create a measure with SWITCH function to count.

Count based on service line =
SWITCH (
    MAX ( 'Table (2)'[Service line 1/2/3] ),
    "Revenue in 1 Service line",
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[Clint name] ),
            FILTER ( 'Table', [Count] = 1 )
        ) + 0,
    "Revenue in 2 Service line",
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[Clint name] ),
            FILTER ( 'Table', [Count] = 2 )
        ) + 0,
    "Revenue in 3 Service line",
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[Clint name] ),
            FILTER ( 'Table', [Count] = 3 )
        ) + 0
)

3.Put the column and the meaesure into a table visual.

vstephenmsft_3-1652084298865.png

 

 

Best Regards,

Stephen Tao

 

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

1 REPLY 1
Anonymous
Not applicable

Hi @SAPpowerbi ,

 

Here's my solutions.

Sample data:

vstephenmsft_0-1652083759621.png

 

1.Create a count measure to count the service line.

Count = CALCULATE(COUNT('Table'[Service Line]),ALLEXCEPT('Table','Table'[Clint name]))

2.Create another three measures to count three situations.

Revenue in 1 Service line = CALCULATE(DISTINCTCOUNT('Table'[Clint name]),FILTER('Table',[Count]=1))+0
Revenue in 2 Service line = CALCULATE(DISTINCTCOUNT('Table'[Clint name]),FILTER('Table',[Count]=2))+0
Revenue in 3 Service line = CALCULATE(DISTINCTCOUNT('Table'[Clint name]),FILTER('Table',[Count]=3))+0

3.Put three measures into a matrix visual, and then switch values to rows.

vstephenmsft_1-1652084164298.png

 

Another solution:

1.Create a table by entering data.

vstephenmsft_2-1652084223256.png

2.Create a measure with SWITCH function to count.

Count based on service line =
SWITCH (
    MAX ( 'Table (2)'[Service line 1/2/3] ),
    "Revenue in 1 Service line",
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[Clint name] ),
            FILTER ( 'Table', [Count] = 1 )
        ) + 0,
    "Revenue in 2 Service line",
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[Clint name] ),
            FILTER ( 'Table', [Count] = 2 )
        ) + 0,
    "Revenue in 3 Service line",
        CALCULATE (
            DISTINCTCOUNT ( 'Table'[Clint name] ),
            FILTER ( 'Table', [Count] = 3 )
        ) + 0
)

3.Put the column and the meaesure into a table visual.

vstephenmsft_3-1652084298865.png

 

 

Best Regards,

Stephen Tao

 

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

 

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