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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
PeteD1302
Helper I
Helper I

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

1 ACCEPTED SOLUTION

I have managed to find a solution from a search for"Re: Conditional Columns or IF Conditions in Direct Query mode" from 04-30-2017. The link as below

https://community.powerbi.com/t5/Desktop/Conditional-Columns-or-IF-Conditions-in-Direct-Query-mode/t...

With the resulting direct query as follows;

IF(Table[Name]="NEW"),"NEW", "OLD

This is for a New Column and helps to identify what are new and old items from a very large SQL server source

 

 

View solution in original post

7 REPLIES 7
v-yuta-msft
Community Support
Community Support

@PeteD1302,

 

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

Capture.PNG 

 

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.

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.

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

Hi, yes I did, dated 02-18-2019 08:28 PM as below

I have managed to find a solution from a search for"Re: Conditional Columns or IF Conditions in Direct Query mode" from 04-30-2017. The link as below

https://community.powerbi.com/t5/Desktop/Conditional-Columns-or-IF-Conditions-in-Direct-Query-mode/t...

With the resulting direct query as follows;

IF(Table[Name]="NEW"),"NEW", "OLD

This is for a New Column and helps to identify what are new and old items from a very large SQL server source

 

Hopes this helps.

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

 

@PeteD1302 ,

 

In DAX, it should be:

Measure =
IF ( CONTAINS ( Table, Table[Name], "NEW" ), "NEW", "OLD" )

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.

 

 

I have managed to find a solution from a search for"Re: Conditional Columns or IF Conditions in Direct Query mode" from 04-30-2017. The link as below

https://community.powerbi.com/t5/Desktop/Conditional-Columns-or-IF-Conditions-in-Direct-Query-mode/t...

With the resulting direct query as follows;

IF(Table[Name]="NEW"),"NEW", "OLD

This is for a New Column and helps to identify what are new and old items from a very large SQL server source

 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.