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.
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.
Solved! Go to Solution.
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!
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!
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! |
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! |
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
99 | |
80 | |
70 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |