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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SO
Helper III
Helper III

Filter table or Matrix

Imagine the table below

 

StaffAnimalHouseColor
ADogBigRed
BCatSmallGreen
CMouseLargeBlue
DCatBigRed
ECamelSmallRed
FCatFishBigRed

 

Using a measure, I'm looking to filter the table so that I can find which staff that have Animals that start with "Cat*"

 

StaffAnimalHouseColor
BCatSmallGreen
DCatBigRed
FCatFishBigRed
Total333


Is this possibe?  I can get counts of Cat* and I can filter with the "Cat*", but I am stuck in producing a table with Counts. 

Thoughts?

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

This is pretty rough, but here is one way to do it. PBIX attached.

 

Measure = 
  IF(HASONEVALUE('Table'[Animal]),
    IF(SEARCH("Cat",MAX('Table'[Animal]),,0) > 0,1,0),
    SUMX(
        ADDCOLUMNS(
            'Table',
            "__Measure",IF(SEARCH("Cat",[Animal],,0) > 0,1,0)
        ),[__Measure]
    )
  )

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

This is pretty rough, but here is one way to do it. PBIX attached.

 

Measure = 
  IF(HASONEVALUE('Table'[Animal]),
    IF(SEARCH("Cat",MAX('Table'[Animal]),,0) > 0,1,0),
    SUMX(
        ADDCOLUMNS(
            'Table',
            "__Measure",IF(SEARCH("Cat",[Animal],,0) > 0,1,0)
        ),[__Measure]
    )
  )

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Wow!

I'm still tying to understand why and how this works, but it does!  

I have not used ADDCOLUMNS or HASONEVALUE so I have some research to do.

Many Thanks again 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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