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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
cn4422
Helper V
Helper V

"Contains Number" with DAX Measure

Hi,

 

I wanted to count all fields that contain a specific product number, in this case 894910000 (then I would create further measures for the other products, containing 894910001, 894910002, etc.)

 

This is the table: 
 
product selection.png
 

So the output should be: 534+105+68+1+270+1+1

 

I created the following measure:

 

Count product_selection Test Multiple Choice =

CALCULATE(COUNT('lead'[Product selection]),
SEARCH("894910000", 'lead'[Product selection], 1, 0)>0)
 
I used the above measure to search for "text" before and it worked, but maybe it does not work for numbers?
 
Thanks! 🙂
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @cn4422 

 

Thank you very much DataNinja777 for your prompt reply. Allow me to add something.

 

I conducted a test for the question you raised.

 

It turns out that both SEARCH and CONTAINSSTRING work with text and numbers.

 

“NUMBER lead”

vnuocmsft_2-1726818145577.png

 

“TEXT lead”

vnuocmsft_3-1726818216938.png

 

 

vnuocmsft_0-1726818079567.png

 

However, please note that in the screenshot you provide, if you change the data type to a number because the data is too large, scientific notation is used. This can have an impact on your measure results.

 

“lead”

vnuocmsft_4-1726819317280.png

 

Therefore, I recommend that you use text-type data for your calculations.

 

Regards,

Nono Chen

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

 

 

 

 

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @cn4422 

 

Thank you very much DataNinja777 for your prompt reply. Allow me to add something.

 

I conducted a test for the question you raised.

 

It turns out that both SEARCH and CONTAINSSTRING work with text and numbers.

 

“NUMBER lead”

vnuocmsft_2-1726818145577.png

 

“TEXT lead”

vnuocmsft_3-1726818216938.png

 

 

vnuocmsft_0-1726818079567.png

 

However, please note that in the screenshot you provide, if you change the data type to a number because the data is too large, scientific notation is used. This can have an impact on your measure results.

 

“lead”

vnuocmsft_4-1726819317280.png

 

Therefore, I recommend that you use text-type data for your calculations.

 

Regards,

Nono Chen

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

 

 

 

 

 

DataNinja777
Super User
Super User

Hi @cn4422 ,

 

Since 'lead'[Product selection] is a text column, the original formula using Search should work for numbers, as Search is designed to handle text strings, including numeric strings within text. However, if the formula isn't working as expected, it's possible that other issues, such as extra spaces or unexpected characters in the text, might be affecting the search.

To confirm if the issue lies with formatting or the presence of extra characters, you could try using TRIM to remove any leading or trailing spaces, or alternatively, Containsstring, which might handle the search more intuitively for your case.

Here’s a more direct version using Containsstring for simplicity:

Count product_selection Test Multiple Choice =
CALCULATE(
    COUNT('lead'[Product selection]),
    CONTAINSSTRING('lead'[Product selection], "894910000")
)

This should work effectively for numeric strings within text columns. Let me know if this resolves the issue!

Best regards,

Hi @DataNinja777 

 

thanks for your reply!

 

Thats really strange... actually I get the following error message:

 

"The data for this visualization was not found.
OLE DB or ODBC error: [Expression.Error] The expression could not be folded for the data source. Try a simpler expression."

@Anonymous @DataNinja777 

Thanks again guys for your effort! 🤗

 

It just didn't work for me in this case but it wouldn't get into my mind why it wouldn't work, because your solutions were absolutely logical.

 

I tried lots of things and finally got it working with basically your formula plus adding an "*"-sign at the end of the string... 😊

 

Count product_selection Test Contain Multiple Choice =
CALCULATE(
    COUNT('lead'[Product selection]),
    CONTAINSSTRING('lead'[Product selection], "894910000*")
)

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors