trying to use a dax query to get a substring value from a different column in ssas tabular

730 views Asked by At

Hi I have a column that looks something like this 052716-JwsDataCSC most of the time and I just want the first part of this the 052716 it would be easy to use left(column,7) but all of the columns are not always the same sometimes I will end up with something like this 053366*DEL-JwsDataCSC and I do want the first part now I know what you are thinking do the find on the - then get everything before it but again its not that simple because I would have something like this 10-453-JwsDataCQC 2 dashes. and I want everything before the last -. So in excel I did this formula =LEFT(A2,FIND("Jws",A2)-2) and this gives me what I want... but this does not work on my tabular model. I created a new calculated column and tried to apply this and all I get is #error no idea why or how to change it. any help would be awesome

enter image description here

2

There are 2 answers

4
Kresimir L. On BEST ANSWER

Please use following measure Column = LEFT(Orders[OrdersAltKey],(FIND("Jws",Orders[OrdersAltKey],1)-2)) you should have enclosed (FIND("Jws",Orders[OrdersAltKey],1)-2) in bracket in order to set right value for left function.

1
josh On

I actually solved this finally. I had a column in my alkey that was coming in as just "unknown", so I did an if statement and it looked like this

=IF(Orders[OrdersAltKey]="unknown","unknown",LEFT(Orders[OrdersAltKey],SEARCH("jws",Orders[OrdersAltKey])-2))