The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello, I was looking for some help as I am quite new to DAX, I was wondering if it is possible to make a column that counts the total number of rows in Batch ID then count the number of instances in the notes column that contains a speific string? I am trying to make a percentage of Batch ID that contains a keyword in the notes. I only want to accomplish this because the batch id is unique and the notes are often duplicated and I need to be able to identify the percentages by method so just counting the notes will not work.
Solved! Go to Solution.
So as far as I understand, Batch column contains unique values and you need pct per Method. Here is the measure:
pct =
VAR method = SELECTEDVALUE ( Table_[Method] )
VAR errorRows =
CALCULATE (
COUNT ( Table_[Batch] ),
CONTAINSSTRING ( Table_[Notes], "Error" ),
Table_[Method] = method
)
VAR allRows = CALCULATE ( COUNT ( Table_[Batch] ), Table_[Method] = method )
RETURN
DIVIDE ( errorRows, allRows, 0 )
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!
You need to do something like this. If this doesn't work, provide more context of your dataset. Happy to help.
Percentage =
VAR _CountRows =
COUNTROWS ( 'Table' )
RETURN
DIVIDE (
_CountRows,
CALCULATE (
COUNT ( 'Table'[Method] ),
ALL ( 'Table' )
)
)
Apologies I think my first post was a bit confusing... here is an example of data for it.
And my desired output is a percentage based on the count of total rows in the batch column that has a note containing "Error" allowing you to sort by method as it is attached to the batch column which is always unique unlike notes.
Hi. Please, provide some demo data and show the desired output.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!
Oops, sorry here is some example data:
Batch Method Notes (String)
1 | Method1 | Correct 07 Jul 2023 |
2 | Method1 | Correct 11 Aug 2023 |
3 | Method2 | Correct 11 Aug 2023 |
4 | Method1 | Correct 19 Sep 2023 |
5 | Method1 | Error 19 Sep 2023 |
My desired output would be the ability to identify the rate at which the notes string contains the phrase error.
Method1 | 20% Error |
Method2 | 0% Error |
So as far as I understand, Batch column contains unique values and you need pct per Method. Here is the measure:
pct =
VAR method = SELECTEDVALUE ( Table_[Method] )
VAR errorRows =
CALCULATE (
COUNT ( Table_[Batch] ),
CONTAINSSTRING ( Table_[Notes], "Error" ),
Table_[Method] = method
)
VAR allRows = CALCULATE ( COUNT ( Table_[Batch] ), Table_[Method] = method )
RETURN
DIVIDE ( errorRows, allRows, 0 )
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!
User | Count |
---|---|
27 | |
12 | |
8 | |
7 | |
5 |
User | Count |
---|---|
31 | |
15 | |
12 | |
7 | |
6 |