Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DAX expression for COUNT of GROUPBY

I am new to PowerBI and writing DAX expressions.

I have a table with a text column with different values.All I want to do is get the count for each distinct value. It's easily achieved with this SQL but I can't get the right DAX expression for it.

select [value],count(*) as TagCount from Tags
group by [value]
order by TagCount desc

Any help?

like image 317
alwayslearning Avatar asked Mar 08 '23 03:03

alwayslearning


1 Answers

You can do something similar in Power BI as follows:

SUMMARIZE(Tags, Tags[value], "TagCount", COUNT(Tags[value]))

or

SUMMARIZECOLUMNS(Tags[value], "TagCount", COUNT(Tags[value]))

You can also do this as a matrix visual with Tags[value] for the Rows and the measure COUNT(Tags[value]) for the Values. You can then sort by whichever column you choose by clicking the column heading on the visual.

like image 112
Alexis Olson Avatar answered Mar 11 '23 05:03

Alexis Olson