Forum Discussion
How to count rows with additional logic (countrows/countx)
- 8 years ago
Hey,
maybe this measure provides what you are looking for.
Countrows Summarize = COUNTROWS( SUMMARIZE('Table1' ,Table1[Task] ,Table1[Config.] ) )It results to 6.
Using SUMMARIZE allows to create a table using just the columns you want.
You can also use
ADDCOLUMNS(
SUMMARIZE(...),"NewColumnName 1", Expression
,...
)For more examples using SUMMARIZE and ADDCOLUMNS please have a look here:
https://www.sqlbi.com/articles/best-practices-using-summarize-and-addcolumns/
Hopefully this is what you are looking for
Regards
Tom
You could add a calculated column that does a CONCATENATE of your two columns and then write a measure that does a DISTINCTCOUNT on that new column.
Measure =
COUNTROWS ( SUMMARIZECOLUMNS ( Table1[Task], Table1[Config.] ) )
this measure creates a table containg all distinct values of the task and config columns and then returns the number of rows in said table
edit: Tom Martens post does the same method just with summarize and add columns instead of summarizecolumns. They should produce the same result and perform the same, summarizecolumns just has simpler syntax.
https://www.sqlbi.com/articles/introducing-summarizecolumns/ to read more about this
- love8 years agoHelper I
Hi Greg_Deckler, TomMartens & Anonymous!
Thank you all for your super quick replies and the proposed solutions - much appreciated. I tried all of them and they work just fine and provide me with what I need. I ended up using TomMartens proposal, it seemed like the most simple solution for my actual data set.
Thanks again and have a nice day!
-L