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.
Hi
Kindly help with a suggestion on DAX, I have a column(DummyDataCarID) and I would like to check if that column has A hyphen (-) and suffixes, and if yes then 1 and if no then 0. Please note dummy data has bee used for example.
DummyDataCarID Expected answer
4645-673 1
7879-785 1
7899-ETW5 1
8906 0
8780 0
Solved! Go to Solution.
Hi @MYDATASTORY
Calc column =
VAR posHyphen_ =
SEARCH ( "-", Table1[CarID], 1, 0 )
VAR anythingAfterHyphen_ =
IF ( LEN ( Table1[CarID] ) > posHyphen_, 1, 0 )
RETURN
IF ( posHyphen_ = 0, 0, anythingAfterHyphen_ )
Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Hi @MYDATASTORY ,
You can use the following DAX:
Hi @MYDATASTORY ,
You can use the following DAX:
Hi @MYDATASTORY
Calc column =
VAR posHyphen_ =
SEARCH ( "-", Table1[CarID], 1, 0 )
VAR anythingAfterHyphen_ =
IF ( LEN ( Table1[CarID] ) > posHyphen_, 1, 0 )
RETURN
IF ( posHyphen_ = 0, 0, anythingAfterHyphen_ )
Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Thanks to your help, I have tried this seems to work but it does not check if there is suffix after the hyphen basically I also want to check if there is suffix after hyphen which can be 6889-DSG3 OR 6889-454, DAX provides is catching the hyphen but it will need to check if there is suffix after the hyphen. Please note this is dummy data.
Hi @MYDATASTORY
It would help if you mention who you're answering to. You say "it will need to check if there is suffix after the hyphen". What on earth does that mean exactly? My code checks whether there is something (doesn't matter what) after the hyphen. What do you want to check exactly. A specific suffix? Only DSG3 or 454? Are those the only two suffixes you are interested in (after the hyphen)?? If so:
Calc column =
IF( SEARCH ( "-DSG3", Table1[CarID], 1, 0 )>0 || SEARCH ( "-454", Table1[CarID], 1, 0 )>0,
1,
0 )
Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
The idea of previous replied solution is those cells have suffixes always contain a hyphen before the suffix. So you can just check whether a cell contains a hyphen. Please update the sample how is your original data included the suffixes in the cell.
Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
80 | |
69 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |