Forum Discussion

PeteD1302's avatar
PeteD1302
Helper I
7 years ago
Solved

DAX Direct Query - if text contains

I have a direct query where I need to add a new column; looking for a part of the text sting and reporting specifed string.

I have viewed a number of posts for IF and CONTAINS and none of the solutions work for a direct query.

e.g. For text string AF - NEW - 5567 if NEW is found then return NEW, if not then OLD

7 Replies

  • v-yuta-msft's avatar
    v-yuta-msft
    Community Support

    PeteD1302,

     

    Click File-> Options-> Direct Query-> Allow unrestricted measures in direct query mode.

     

     

    Community Support Team _ Jimmy Tao

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      I am trying to use Search or ContainsString function in Direct Query mode but getting the same error that these functions are not supported in direct query model. However in the list of optimized dax functions they are listed.

      Also, there is no option in the latest power bi desktop version to allow unrestricted measures in direct query mode.

      Please help as this issue has become a major bottleneck for us.

      • cklopper's avatar
        cklopper
        Frequent Visitor

        Anonymous , I'm struggling with this too - did you find a good work-around?

    • PeteD1302's avatar
      PeteD1302
      Helper I

      Jimmy Tao, I made the suggested change.

      I am still having issue with correct DAX command, which is correct or none.

      e.g.

      IF (Text.Contains('Table'[Name], "NEW") then NEW else "OLD

      or IF ('Table'[Name], Text.Contains ("NEW"), then NEW else OLD

      or IF (CONTAINSROW('Table'[Name], "NEW") then"NEW" else OLD

      or  IF ('Table'[Name], CONTAINSROW ("NEW") then NEW else OLD