DAX - Finding specific value/text within Column

FanofExcel18

Board Regular
Joined
Jun 7, 2018
Messages
65
I am trying to figure out the correct measure and/or column DAX operation to extract whether another column has a specific string of characters. See example below as to what results I am attempting to achieve.

Example:
Column DataResults
Testing 1.0 for Deployment1.0
Testing 2.0 for Deployment2.0
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi,

Do you always want to return the version number from your string? If yes, and assuming these are always 3 characters long, I'd suggest using the following column (DAX):

Rich (BB code):
Result = 
    var charPos = SEARCH(".", 'Table'[Column Data], 1, 0)
return
    IF(charPos, MID('Table'[Column Data], charPos - 1, 3))

1587577153467.png
 
Upvote 0
Hi,

Do you always want to return the version number from your string? If yes, and assuming these are always 3 characters long, I'd suggest using the following column (DAX):

Rich (BB code):
Result =
    var charPos = SEARCH(".", 'Table'[Column Data], 1, 0)
return
    IF(charPos, MID('Table'[Column Data], charPos - 1, 3))

View attachment 12081
Does it matter if the character's within the source cell could vary? Meaning cell 1's character length is 20 and the version would be at the 10th character. The 2nd cell would be character length of 30 and version start at 15th character.
 
Upvote 0
Good question - the length of the original string ("Column Data") won't matter - variable charPos will still return a proper location of a dot "." character. However, bear in mind that my current code is assuming that:
1. your version number (e.g. 1.0, 2.0) is always 3-characters long
2. there is only one dot "." in the original string ("Column Data").

If you see some unexpected result then feel free to share a screenshot.
 
Upvote 0
Good question - the length of the original string ("Column Data") won't matter - variable charPos will still return a proper location of a dot "." character. However, bear in mind that my current code is assuming that:
1. your version number (e.g. 1.0, 2.0) is always 3-characters long
2. there is only one dot "." in the original string ("Column Data").

If you see some unexpected result then feel free to share a screenshot.
This is perfect thank you! I do have a follow up and I may need to post new.

So I used the DAX column suggested. I've setup a Matrix table with a Name as a Row, Dax Column as a Column, and Values is a Distinct Count of Column 1.
Name1.02.03.0
ABC Org11
DEF Org1
GHI Org11
JKL Org111

I would like to simply be able to tell all the Name's that only have 3.0 excluding the ones that have 1.0 or 2.0 including 3.0. I can filter but that doesn't filter the ones that also have 1.0 and 2.0
 
Upvote 0
You might want to create a new DAX measure that counts all instances of versions that are not equal to 3.0 -

Rich (BB code):
CountExcl3.0 = 
    CALCULATE(
        COUNT('Table'[Result]),
        FILTER('Table', 'Table'[Result] <> "3.0")
    )

As you can see in this table, DEF Org is not visible -
1587582036494.png


Now that we know our measure is working correctly, you can apply it to your matrix, i.e. CountExcl3.0 is blank -
1587582062490.png
 
Upvote 0
You might want to create a new DAX measure that counts all instances of versions that are not equal to 3.0 -

Rich (BB code):
CountExcl3.0 =
    CALCULATE(
        COUNT('Table'[Result]),
        FILTER('Table', 'Table'[Result] <> "3.0")
    )

As you can see in this table, DEF Org is not visible -
View attachment 12092

Now that we know our measure is working correctly, you can apply it to your matrix, i.e. CountExcl3.0 is blank -
View attachment 12093
Unforunately, its not working.
 
Upvote 0
Can you share some screenshots along with an example of your dataset? That would help with troubleshooting.
 
Upvote 0

Forum statistics

Threads
1,223,793
Messages
6,174,635
Members
452,575
Latest member
Fstick546

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top