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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
johnmelbourne
Helper V
Helper V

Use countrows and seacrh or find ... or something different

Hi,

 

I am looking for different functions to do the following, perhaps using countrows and search or find but I am not getting the syntax correct.

 

In english, find where the


Total successful = CALCULATE([MeasureName], Category[Category] = "Successfully completed and stayed" || Category[Category] = "Successfully completed and left")

The above works fine, but I am looking to do a different way using new functions.

 

Any assistance appreciated.

 

 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @johnmelbourne ,

 

You may create a measure as below:

_Total successful = 
var _search1=SEARCH("Successfully completed and stayed",MAX('Category'[Category]),1,0)
var _search2=SEARCH("Successfully completed and left",MAX('Category'[Category]),1,0)
Return
CALCULATE([Measure name],FILTER('Category',_search1<>0||_search2<>0))

Or a measure as below:

_Total successful 1 = 
var _search=CALCULATE(COUNTROWS(FILTER('Category','Category'[Category]=MAX('Category'[Category]))),'Category'[Category]="Successfully completed and stayed" || Category[Category] = "Successfully completed and left")+0
Return
CALCULATE('Category'[Measure name],FILTER('Category',_search<>0))

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

5 REPLIES 5
v-kelly-msft
Community Support
Community Support

Hi @johnmelbourne ,

 

You may create a measure as below:

_Total successful = 
var _search1=SEARCH("Successfully completed and stayed",MAX('Category'[Category]),1,0)
var _search2=SEARCH("Successfully completed and left",MAX('Category'[Category]),1,0)
Return
CALCULATE([Measure name],FILTER('Category',_search1<>0||_search2<>0))

Or a measure as below:

_Total successful 1 = 
var _search=CALCULATE(COUNTROWS(FILTER('Category','Category'[Category]=MAX('Category'[Category]))),'Category'[Category]="Successfully completed and stayed" || Category[Category] = "Successfully completed and left")+0
Return
CALCULATE('Category'[Measure name],FILTER('Category',_search<>0))

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

CNENFRNL
Community Champion
Community Champion

Hi, @johnmelbourne , a fundamental alternative to your measure is like 

Total successful =
CALCULATE (
    [MeasureName],
    Category[Category]
        IN { "Successfully completed and stayed", "Successfully completed and left" }
)

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

AllisonKennedy
Super User
Super User

Hi John~

Sorry, I'm not following what you need? In English find where the .... did you mean to write more there?

Are you just looking to learn more DAX functions or is there a future/further business requirement that is inspiring you to change a measure that's currently working?

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hi,

 

Sorry, I only half typed it looks like.

 

 

In english, I am tryin to write a measure where it says find where the category contains the words "Successfully completed".

 

I just trying to learn a new way of summing values when a cetegory contains a part of a string.

 

So eg; what search ? / find ? / match ? DAX function would you use to calculate
Sum [Sales] where Product[ProductName] contains the word "health"

 

When product names might be

Health Gel

Health socks

General health

Physical health

Mental health

 

Any assistance appreciated.

You may try

Measure =
CALCULATE (
    COUNTROWS ( 'Product' ),
    SEARCH ( "health", 'Product'[ProductName],, FALSE () )
)

MATCH() isn't available in DAX native function lib. Similar to Excel, SEARCH() is not case-sensitive whereas FIND() is so.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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