The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Trying to count rows in a table and give a measure for how many rows contain the string "Very" in the Description column for each Colour. Everything I have tried counts the number of rows that have very in the whole table (in this case 6), so the third column in my table is incorrect. The third column used the calculated column:-
The last column " Count of "Very" for each colour" is the desired output, which is a count of the number of rows containing "Very" for each colour
Colour | Description | COUNTIF COLOUR FOR Very | Confirmed | Count of "Very" for each colour |
Blue | Very Dim | 6 | Yes | 1 |
Blue | Dim | 6 | 1 | |
Blue | Bright | 6 | 1 | |
Blue | Slightly Dull | 6 | 1 | |
Green | Very Bright | 6 | 2 | |
Green | Very Dim | 6 | 2 | |
Green | Dim | 6 | Yes | 2 |
Green | Bright | 6 | 2 | |
Green | Slightly Dull | 6 | 2 | |
Red | Very Bright | 6 | 3 | |
Red | Very Dim | 6 | 3 | |
Red | Dim | 6 | Yes | 3 |
Red | Bright | 6 | 3 | |
Red | Slightly Very Dull | 6 | 3 |
Solved! Go to Solution.
Thank you for your prompt reply! @parry2k
Hi @rockingmark
Please try the following measure:
Measure =
VAR _color = SELECTEDVALUE(Brightness[Colour])
RETURN
CALCULATE(COUNTROWS('Brightness'),FILTER(ALL('Brightness'),'Brightness'[Colour]=_color && CONTAINSSTRING('Brightness'[Description],"Very")=TRUE()))
This is the result you want:
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you for your prompt reply! @parry2k
Hi @rockingmark
Please try the following measure:
Measure =
VAR _color = SELECTEDVALUE(Brightness[Colour])
RETURN
CALCULATE(COUNTROWS('Brightness'),FILTER(ALL('Brightness'),'Brightness'[Colour]=_color && CONTAINSSTRING('Brightness'[Description],"Very")=TRUE()))
This is the result you want:
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Many Thanks Jayleny, exactly what I wanted
@rockingmark if you want to show the count for each row of the color then do this:
Very =
VAR __Color = Color[Colour]
RETURN
CALCULATE (
COUNTROWS ( Color ),
FILTER (
ALL ( Color[Colour], Color[Description ] ),
Color[Colour] = __Color &&
CONTAINSSTRING ( Color[Description ], "Very" )
)
)
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi parry2k,
Thanks for this solution. I used it to make a new column (hope that was the intention)
This solution resulted in rows with blank values as shown below. Couldn't understand why, especially as some of the rows that dont have the word "Very" in the description got a count result in the "Very" column and some didnt'.
Could you explain why it worked that way, to help my understanding of dax
I would like all rows for very column very to be populated.
@rockingmark try this, change the column and table name as per your model
Very =
VAR __Color = Color[Colour]
RETURN
CALCULATE ( COUNTROWS ( Color ), FILTER ( ALL ( Color[Colour] ), Color[Colour] = __Color && CONTAINSSTRING ( Color[Description ], "Very" ) ) )
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
104 | |
97 | |
80 | |
62 | |
57 |
User | Count |
---|---|
264 | |
120 | |
115 | |
83 | |
70 |