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

Counting multiple matches

Hi. New to this forum so hope my post is clear.

I have a table of campaign formats:

Format
Digital
HPP
SPP
Others

I have a table of campaigns which can have 1 or more formats (NB not separated by commas or similar):

CampaignFormat
C10Digital
C11HPP
C12Digital HPP
C13HPP
C14HPP SPP
C15SPP
C16Digital Others
C17Digital HPP Others
C18Others
C19Others SPP
C20SPP

I want to be able to calculate:
a) Numbers of formats per campaign:

CampaignFormatCount of Formats
C10Digital1
C11HPP1
C12Digital HPP2
C13HPP1
C14HPP SPP2
C15SPP1
C16Digital Others2
C17Digital HPP Others3
C18Others1
C19Others SPP2
C20SPP1
  17

b) Count of Formats

FormatCount
Digital4
HPP5
SPP4
Others4
 17

I have tried numerous variations of Contains, Search, Find, Filter but have not yet found a solution that works. Any suggestions gratefully received.

5 REPLIES 5
Ben_G
Frequent Visitor

@Icey 

That worked perfectly. Thanks very much.
Could you possibly help me with the next level of complexity?

Each campaign has a value and I want to be able to calculate the value per format exactly as per the way formats has been done, ie any campaign that includes one of the selected formats. PBIX file linked below. Thanks in advance 🤞

Ben_G_0-1654258061633.png

PBIX file 

Icey
Community Support
Community Support

Hi @Ben_G ,

 

Can this work in your scenario?

Measure =
SUMX (
    VALUES ( FormatTable[Format] ),
    CALCULATE (
        COUNTROWS (
            FILTER (
                ( CampaignTable ),
                CONTAINSSTRING ( CampaignTable[Format], MAX ( FormatTable[Format] ) )
            )
        )
    )
)

Icey_0-1654074336139.png

 

 

 

Best Regards,

Icey

 

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

Ben_G
Frequent Visitor

Hi @Fowmy Thanks for the prompt response.
Additional info. I provided a small subset of data. However some of the entries in my full list of campaigns comprise 2 words (eg New Channel) so splitting by space delimiter may not be effective.
Any thoughts?

@Ben_G 

There has to be a logic and consistency in that case. If you can somehow identify the list of campaigns, it will solve the problem.
Please let me know if you have any suggestions as you are familiar with your dataset.


 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Fowmy
Super User
Super User

@Ben_G 

I used Power Query to split the formats, please check the attached file.

Fowmy_0-1653834750752.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.