问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/46084978/dax-expression-for-count-of-groupby