Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
So I am new to the DAX world and this is giving me a headache. I have multiple rows of IDs and I need to count how many unique customers for each ID. Column three is what I would like to see in my table as a created column in the example below. If it is possible! Thanks
Solved! Go to Solution.
This will do it without invoking CALCULATE, which can cause problems in a Calculated Column.
Customer Count =
VAR varCurrentID = Records[ID]
VAR varCustomerCount =
COUNTROWS(
DISTINCT(
SELECTCOLUMNS(
FILTER(
Records,
Records[ID] = varCurrentID
),
"@Customers", Records[Customer]
)
)
)
RETURN
varCustomerCount
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingI have a similar query, but the problem is that my data is spread across a given time period. So the query above is not helping.
This is what my data looks like:
I have unique user IDs, the number of sessions for that ID on a given date.
Now i want to create a basic line chart which can show the cumulative number of sessions per unique user.
Please help.
Hi @Jess303 ,
According to your description, here's my solution.
Create a calculated column.
Count of customers =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Customer] ),
FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) )
)
Get the expected result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This will do it without invoking CALCULATE, which can cause problems in a Calculated Column.
Customer Count =
VAR varCurrentID = Records[ID]
VAR varCustomerCount =
COUNTROWS(
DISTINCT(
SELECTCOLUMNS(
FILTER(
Records,
Records[ID] = varCurrentID
),
"@Customers", Records[Customer]
)
)
)
RETURN
varCustomerCount
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingI get this error message. When I run the DAX:
DAX comparison operations do not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.
However both are type integer. I tried to change them to text it did not work.
You need to show the info. I just redid it using all numbers and converting both to integer. My DAX didn't change.
How to get good help fast. Help us help you.
How To Ask A Technical Question If you Really Want An Answer
How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingStarting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
25 | |
21 | |
20 | |
14 | |
13 |
User | Count |
---|---|
43 | |
37 | |
25 | |
24 | |
23 |