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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
apoorvsi
Helper I
Helper I

Use filter and REMOVEFILTERS for same measure

Hi, 

I am fairly new to PBI and have a requirement that I am unable to convert to DAX. 

I have a measure called ReUseCount which counts for the occurence of a component in different companies. This Company is also used as a slicer in the same page.

 

I have used the following DAX:

 

calculate ( DISTINCTCOUNT('Component Name'[Component Name]),
,Filter('Component Name',
CALCULATE (
DISTINCTCOUNT ('Fact'[Company])
,REMOVEFILTERS ( Company[Company Name] )
)>1 )

 

Example: 

CompanyA     Component1

CompanyB     Component1

CompanyB     Component2

CompanyC     Component2

CompanyC      Component3

 

Expected result: When all companies are selected, I get output 2 (Components 1,2 are reused i.e. present in more than 1 company) which is correct. However, when the Company is filtered, say CompanyA, I still get output 2 whereas it should be 1 (Only Component1 of CompanyA is reused)

 

Please help. TIA.

 

 

 

   

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@apoorvsi try this measure

 

Measure 3 = 
CALCULATE (
    DISTINCTCOUNT ('Table (2)'[Component] ), 
    FILTER ( 
        SUMMARIZE ( 
            ALL ('Table (2)' ),
            'Table (2)'[Component],
            "cnt", DISTINCTCOUNT ( 'Table (2)'[Company] ) 
        ),
        [cnt] > 1
    )
)

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

10 REPLIES 10
parry2k
Super User
Super User

@apoorvsi try this measure

 

Measure 3 = 
CALCULATE (
    DISTINCTCOUNT ('Table (2)'[Component] ), 
    FILTER ( 
        SUMMARIZE ( 
            ALL ('Table (2)' ),
            'Table (2)'[Component],
            "cnt", DISTINCTCOUNT ( 'Table (2)'[Company] ) 
        ),
        [cnt] > 1
    )
)

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k , coming to you for a related doubt.

How may I convert:

FILTER ( 
        SUMMARIZE ( 
            ALL ('Table (2)' ),
            'Table (2)'[Component],
            "cnt", DISTINCTCOUNT ( 'Table (2)'[Company] ) 
        ),
        [cnt] > 1

 to a table? I need to use this in intersect function.

Basically, need all Components with distinct count of company >1 and compare their presence in :

 

FILTER ( 
        SUMMARIZE ( 
            'Table (2)',  -- filtered
            'Table (2)'[Component],
            "cnt", DISTINCTCOUNT ( 'Table (2)'[Company] ) 
        ),
        [cnt] > 1

 

amitchandak
Super User
Super User

Try a measure like

countx(filter(summarize(table, table[company],table[Component], "_1", calculate(count(table[company]),filter(all(Table), table[Component] =max(table[Component])))),
[company] in values(table[company])),[Component])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak , thanks for replying, I am not sure I understand the use of table[Component] =max(table[Component]))
Could you please elaborate?

@apoorvsi did you tried the solution I provided.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k , thanks, I am working with the measure you provided but it is not returning expected values. I think I should have mentioned that the source is not the same table. The companies to be counted are from fact and the components are from dimension.

 

 CALCULATE (
DISTINCTCOUNT ('Component Name'[Component Name] ),
FILTER (
SUMMARIZE (
ALL ('Component Name' ),
'Component Name'[Component Name],
"cnt", CALCULATE (
DISTINCTCOUNT ('Fact'[CompanyPk])
--,FILTER(ALL('Execution Date'),'Execution Date'[Execution Date] >= StartDate && 'Execution Date'[Execution Date] <= EndDate )
)),[cnt]>1
))
 
Do you see any issues?

@apoorvsi this is totally different but logically it should work, how these tables are related, can you share real-time model scenario with sample data.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k ,

 

Sharing the sample data:

 

Fact Table

ComponentNamePkCompanyPkEntityId
100237AP_001
100246AP_001
100346AP_002
100337AP_002
189169AP_002
42519AP_001
69827AP_001
69837AP_001
69846AP_001
69846AP_004

 

Dim Company Table:

 

CompanyPkCompanyName
37abc
46xyz
69tef
9ghg
27fdjkf


Dim Component Table:

ComponentNamePkComponentNameEntityId
1002componentname1AP_001
1891blocrtAP_001
4251okerAP_001
698monitoringAP_001
5258componentname1AP_002
655blocrtAP_005
658okerAP_003
586monitoringAP_002

 

The granularity of Dim Component is not based only on name, rather the name and an entity ID. I only want to consider the entity ID AP_001 which I am filtering out in my visual.

Hi @parry2k , I tried using all fields from fact itself and it sems to work now.. thank you very much!! I'll check some more.  

@apoorvsi good to know. cheers!!

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.