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.
Hi all - newbie here. I am trying to add a calculated column that shows a count of occurrences of "Member" in my dataset. I have a single data table, direct query from SQL. I've been researching options here and Reddit but I can't use things like COUNT, COUNTDISTINCT in a column because of direct query. I've also tried some formulas here with EARLIER such as ..
Thanks in advance!
Solved! Go to Solution.
Hi @TeaBags ,
Based on your description, you can't use count or countdistinct in data fetched in Direct Query mode. you might want to consider creating a view on the sql side first to aggregate this data. For example, you can use
CREATE VIEW MemberCount AS
SELECT Member, COUNT(*) AS Occurrences
FROM Table
GROUP BY Member;
Then when you get to the database view in Direct Query mode, you can use this dax expression
Member Occurrences = COUNTROWS(FILTER(Table, Table[Member] = "Member"))
That might accomplish your goal.
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @TeaBags ,
Based on your description, you can't use count or countdistinct in data fetched in Direct Query mode. you might want to consider creating a view on the sql side first to aggregate this data. For example, you can use
CREATE VIEW MemberCount AS
SELECT Member, COUNT(*) AS Occurrences
FROM Table
GROUP BY Member;
Then when you get to the database view in Direct Query mode, you can use this dax expression
Member Occurrences = COUNTROWS(FILTER(Table, Table[Member] = "Member"))
That might accomplish your goal.
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thanks Albert! That did the trick for my immediate need as I have full access to the SQL instance being used.
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 |
---|---|
100 | |
99 | |
76 | |
66 | |
60 |
User | Count |
---|---|
142 | |
106 | |
103 | |
85 | |
70 |