Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have the following query to calculate the TOP 10 commented videos for a specific month and year :
SELECT TOP 10 videoId
,COUNT(commentId) AS CountComments FROM dbo.VideoComments
WHERE MONTH(publishedAt)=12
AND YEAR(publishedAt)=2020
GROUP BY
videoId
,MONTH(publishedAt)
ORDER BY countcomments DESC
I want to implement the same logic using DAX where Month and Year are filters.
Solved! Go to Solution.
@amirabedhiafi , you can use TOPN for that
Better to one field month year , assume you have measure -CountComments
Top 10 City Rank = CALCULATE([CountComments ],TOPN(10,all(Table[Month Year]),[CountComments ],DESC),VALUES(Table[Month Year))
TOPN -https://www.youtube.com/watch?v=QIVEFp-QiOk
For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
@amirabedhiafi , you can use TOPN for that
Better to one field month year , assume you have measure -CountComments
Top 10 City Rank = CALCULATE([CountComments ],TOPN(10,all(Table[Month Year]),[CountComments ],DESC),VALUES(Table[Month Year))
TOPN -https://www.youtube.com/watch?v=QIVEFp-QiOk
For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
are you table to provide some sample data?
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
97 | |
80 | |
69 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |