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
Greatbi1
Frequent Visitor

count of common values - only using DAX

Hi All,

 

I have this is in continuation of Old post . An awsome solution was given by @camargos88 using power query - join. Now I have realised that raw data size is huge and I need multiple charts and foreach combination I don't want to create join. I want to do it using DAX alone. Is it possible?

 

I have data like below:

State | Engineer| 

Florida, Johny

Florida, Nick

Indiana, Johny

Indiana, Nick

 

I want a pivot table like below which shows common engineer between states.

 

StateFloridaIndiana
FloridaNA1
Indiana1NA

 

 

Santhosh K

1 ACCEPTED SOLUTION
stevedep
Memorable Member
Memorable Member

Here you go:

In case you do not want to create a relationship between your base table the filter table:

 

EngineerCount = 
VAR EngineerCount = VALUES('Table'[Engineer])
VAR FilterEngineerCount = CALCULATETABLE(VALUES('Table'[Engineer]);ALL('Table');TREATAS(VALUES(FilterStates[State]); 'Table'[State]))

RETURN
COUNTROWS(INTERSECT(EngineerCount;FilterEngineerCount))

 

 

In case you can create an inactive relationship:

 

EngineersinBotStates = 
CALCULATE (
    DISTINCTCOUNT ('Table'[Engineer] );
    CALCULATETABLE (
        SUMMARIZE ( 'Table';'Table'[Engineer] );
        ALL ( 'Table');
        USERELATIONSHIP ( 'Table'[State]; FilterStates[State] )
    )
)

 

Which is based on this article:

https://www.daxpatterns.com/basket-analysis/

 

Result can be seen here, please note the data model and the use of a filtered states table, which is created with:

 

FilterStates = SUMMARIZE('Table';'Table'[State])

 

2020-06-14_10-08-27.gif

File is available here

 

Please mark as solution if this works for you. Thumbs up for the effort is appreciated.

Kind regards, Steve. 

View solution in original post

2 REPLIES 2
stevedep
Memorable Member
Memorable Member

Here you go:

In case you do not want to create a relationship between your base table the filter table:

 

EngineerCount = 
VAR EngineerCount = VALUES('Table'[Engineer])
VAR FilterEngineerCount = CALCULATETABLE(VALUES('Table'[Engineer]);ALL('Table');TREATAS(VALUES(FilterStates[State]); 'Table'[State]))

RETURN
COUNTROWS(INTERSECT(EngineerCount;FilterEngineerCount))

 

 

In case you can create an inactive relationship:

 

EngineersinBotStates = 
CALCULATE (
    DISTINCTCOUNT ('Table'[Engineer] );
    CALCULATETABLE (
        SUMMARIZE ( 'Table';'Table'[Engineer] );
        ALL ( 'Table');
        USERELATIONSHIP ( 'Table'[State]; FilterStates[State] )
    )
)

 

Which is based on this article:

https://www.daxpatterns.com/basket-analysis/

 

Result can be seen here, please note the data model and the use of a filtered states table, which is created with:

 

FilterStates = SUMMARIZE('Table';'Table'[State])

 

2020-06-14_10-08-27.gif

File is available here

 

Please mark as solution if this works for you. Thumbs up for the effort is appreciated.

Kind regards, Steve. 

Thank you steve for detailed explanantion. I really appreciate your approach.

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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