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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
dosinkevic
Frequent Visitor

CountIF text contains ID

Hello guys,

I'm new to PorweBI and writing Query formulas is super hard for me.

I'm trying to get same result as in GoogleSheets =COUNTIF(sales!L:L,"*"&CampaignID&"*")

I have two queries:

CAMPAIGN

 

id,     Campaign name,        spend
8745,   camp_1,               50
8456,   camp_2,               30
7763,   camp_3,               20

CRM

trans_id,  product,       camp_tracker
0012,      hat,           hat_8745_may
0013,      t-shirt,       t-shirt_8456_june
0014,      sneakers,      sneakers_7763_june
0015, hat, hat_8745_june

 

 I need to calculate if Campaign ID is in CRM column camp_tracker. I'm expecting result like that:

id,     Campaign name,        spend,  count_sales
8745,   camp_1,               50,     2
8456,   camp_2,               30,     1
7763,   camp_3,               20,     1

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Create a column in your CAMPAIGN table like this:

 

Column = 
VAR __tmpTable = ADDCOLUMNS(ALL(crm),"Found",FIND([id],[camp_tracker],,-1))
RETURN COUNTROWS(FILTER(__tmpTable,[Found]<>-1))


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

Create a column in your CAMPAIGN table like this:

 

Column = 
VAR __tmpTable = ADDCOLUMNS(ALL(crm),"Found",FIND([id],[camp_tracker],,-1))
RETURN COUNTROWS(FILTER(__tmpTable,[Found]<>-1))


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler, thank you very much! I was googling for hours..

 

Do you know is it possible to upgrade this function with IF statement?
If Campaign {"date"} = CRM {"date"} then Sales_count =...

alexei7
Continued Contributor
Continued Contributor

Hi @dosinkevic,

 

I presume that you have the campaign id field in your "CRM" table.

 

If you do, then you should be able to create a measure in CRM which is just "count_sales = COUNTROWS(CRM)

 

Then, in a table visualisation in Power BI, bring in all the fields from your Campaign table, and the new "count_sales" measure you've just created.

 

Hope that helps,

Alex

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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