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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
cn4422
Helper I
Helper I

"Contains" in Dax measure - workaround wanted

Hi guys,

 

I'm using the following DAX measure:

Sum Spend =
CALCULATE(SUM('FB_GA_GA4_This Year'[spend]),
'FB_GA_GA4_This Year'[account_name]="AC01" && 'FB_GA_GA4_This Year'[campaign]="[AT]-Lead-Ads-2024")
 
So I'm filtering by Account Name and Campaign Name.
The thing is, I have more campaigns, all starting with [AT]... and I would like to put something like "Contains [AT]", which doesn't work. Also, in the future there might be more campaigns added, so it needs to be automatic.
 
Do you know of any good workaround for this problem?
 
Thx in advance! 😊
 
 
1 ACCEPTED SOLUTION

Sum Spend FB AT Test Filter =
CALCULATE(SUM('FB_GA_GA4_This Year'[spend]),
'FB_GA_GA4_This Year'[account_name] && SEARCH("[AT]"'FB_GA_GA4_This Year'[campaign]10)>0)

View solution in original post

9 REPLIES 9
lbendlin
Super User
Super User

You can use FIND/SEARCH or LEFT  for that

 

Text functions (DAX) - DAX | Microsoft Learn

Thanks for your reply.

 

I tried LEFT, but couldn't mange to get it working.

 

Then I tried the following with SEARCH:

Sum Spend FB AT Test Filter =
CALCULATE(SUM('FB_GA_GA4_This Year'[spend]),
'FB_GA_GA4_This Year'[account_name] && SEARCH("[AT]", 'FB_GA_GA4_This Year'[campaign], 1, 0))

However, I get the following error message:
Cannot convert value '02 GA4' of type Text to type True/False.
 
Any idea about that?
 
 

Sum Spend FB AT Test Filter =
CALCULATE(SUM('FB_GA_GA4_This Year'[spend]),
'FB_GA_GA4_This Year'[account_name] && SEARCH("[AT]"'FB_GA_GA4_This Year'[campaign]10)>0)

Hi,

one more question regarding this issue.

Is it possible to include an "or"-condition for the SEARCH("[AT"]... - something like:
SEARCH("[AT]" || "[DE]",

Yes, run two searches and OR the results.

Like this?
 
CALCULATE(SUM('FB_GA_GA4_This Year'[spend]),
'FB_GA_GA4_This Year'[account_name] && SEARCH("[AT]"'FB_GA_GA4_This Year'[campaign]10)>0) ||
'FB_GA_GA4_This Year'[account_name] && SEARCH("[DE]", 'FB_GA_GA4_This Year'[campaign], 1, 0)>0)
 
 

Hm, unfortunately the same error message keeps appearing... 🤔

Do you have any other suggestions? 

What's 'FB_GA_GA4_This Year'[account_name]  supposed to do?

Ahh, my bad, it worked, I just had a typo in it.

Thank you so much, made my day! 🤗

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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