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

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.

Reply
Lcouch
New Member

DAX Function on FILTER with like?

Hello,

 

Can I create a measure when I filter on a value like I have Servicebus below- use Like %Servicebus% as we do in SQL?

 

The column in the tables has various values with this word and I need all of them returned. I did get an error with typing it as above.

 

 

Total Of ALMM Service Bus Actions =
CALCULATE(COUNTA('VIEW_ALMMTaskRequestDetails'[CreatedBy]), FILTER('VIEW_ALMMTaskRequestDetails', 'VIEW_ALMMTaskRequestDetails'[ResourceType] ="Servicebus"))  --- see above need to get a count of all with this word in it
 
 
 
Thank you!!!
1 ACCEPTED SOLUTION

Hi @Lcouch 

The code you displayed is not the same as mine:

Total Of ALMM Service Bus Actions =
COUNTAX(FILTER('VIEW_ALMMTaskRequestDetails', CONTAINSSTRING('VIEW_ALMMTaskRequestDetails'[ResourceType] ,"Servicebus")) ,[CreatedBy])

Maybe you can try the code above again

 

Best Regards!

 

Yolo Zhu

View solution in original post

9 REPLIES 9
v-xinruzhu-msft
Community Support
Community Support

Hi @Lcouch 

 

You can try the following code:

 

 

Total Of ALMM Service Bus Actions =
COUNTAX(FILTER('VIEW_ALMMTaskRequestDetails', CONTAINSSTRING('VIEW_ALMMTaskRequestDetails'[ResourceType] ,"Servicebus")) ,[CreatedBy])

 

 

Best Regards,

Yolo Zhu

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

@v-xinruzhu-msft 

When I tried

Total Of ALMM Service Bus Actions = COUNTAX(FILTER('VIEW_ALMMTaskRequestDetails', 'VIEW_ALMMTaskRequestDetails'[ResourceType] ="Servicebus") ,[CreatedBy])

I get the same result as when I use 

 

Total Service Bus Provisions =

CALCULATE(COUNTA('VIEW_SBFuncAppWebAppEventHubs'[Name]), FILTER('VIEW_SBFuncAppWebAppEventHubs', 'VIEW_SBFuncAppWebAppEventHubs'[Type]="ServiceBus") )

 

 

it gives me the count.. but for any types that have 'ServiceBus' as part of the name but it is not the only spelling.. it doesnt return them

Hi @Lcouch 

The code you displayed is not the same as mine:

Total Of ALMM Service Bus Actions =
COUNTAX(FILTER('VIEW_ALMMTaskRequestDetails', CONTAINSSTRING('VIEW_ALMMTaskRequestDetails'[ResourceType] ,"Servicebus")) ,[CreatedBy])

Maybe you can try the code above again

 

Best Regards!

 

Yolo Zhu

Manoj_Nair
Solution Supplier
Solution Supplier

@Lcouch - Try this calculated column DAX as below shown.

Manoj_Nair_0-1670029317599.png

 

@Lcouch 

Oops!! I missed copying the DAX. Let me know if this fixes your problem

 

Total Of ALMM Service Bus Actions = 
IF (
    SEARCH (
        "Servicebus",
        VIEW_ALMMTaskRequestDetails[ResourceType],
        1,
        0
    ) > 0,
    "Servicebus",
    BLANK ()
)

 

 

Hi!

 

Thank you @Manoj_Nair  but it doesnt count CreatedBy

 

So my current function is

 

Total Of ALMM Service Bus Actions =

CALCULATE(COUNTA('VIEW_ALMMTaskRequestDetails'[CreatedBy]), FILTER('VIEW_ALMMTaskRequestDetails', 'VIEW_ALMMTaskRequestDetails'[ResourceType] ="Servicebus"))

 

and the one you provide is below but no count of createdy by

Total Of ALMM Service Bus Actions = IF ( SEARCH ( "Servicebus", VIEW_ALMMTaskRequestDetails[ResourceType], 1, 0 ) > 0, "Servicebus", BLANK () )  

Greg_Deckler
Super User
Super User

@Lcouch You can use CONTAINSSTRING. Doesn't do the % wildcards but otherwise might work. CONTAINSSTRING function (DAX) - DAX | Microsoft Learn


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler - 

 

I get an error when I tried:

 

Total Of ALMM Service Bus Actions =

 

CALCULATE(COUNTA('VIEW_ALMMTaskRequestDetails'[CreatedBy]), FILTER('VIEW_ALMMTaskRequestDetails', ('VIEW_ALMMTaskRequestDetails'[ResourceType] CONTAINSSTRING("Servicebus"))

 

Also tried:

Total Of ALMM Service Bus Actions =

CALCULATE(COUNTA('VIEW_ALMMTaskRequestDetails'[CreatedBy]), EVAULATE ROW('VIEW_ALMMTaskRequestDetails', ('VIEW_ALMMTaskRequestDetails'[ResourceType] CONTAINSSTRING("Servicebus"))

 

(removed the filter even though I need that filter) but it didnt like Evaluate

@Lcouch

CONTAINSSTRING takes 2 parameters:

CONTAINSSTRING(<within_text>, <find_text>)

So try:

CALCULATE(COUNTA('VIEW_ALMMTaskRequestDetails'[CreatedBy]), CONTAINSSTRING('VIEW_ALMMTaskRequestDetails'[ResourceType], "Servicebus"))


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors