Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Anonymous
Not applicable

Count DAX

Hi Community,

I have the following table:

Project IDProject Sub IDValue
100100A10
100100B20
100100B30
101101A40
102102A60
102102B80
102102C90
102102C35
102102C42

I want to create a measure that distinct counts the number of project id repeated in the table, so the following output will be like this:

Project Sub IDCount Measure
100A2
100B2
101A1
102A3
102B3
102C3

Any directions or thought would be appreciated!

Edit: Updated the output of the orignal as I put in the wrong output

1 ACCEPTED SOLUTION

@Anonymous 

please try to create a measure

Measure = CALCULATE(DISTINCTCOUNT('Table'[Project Sub ID]),FILTER(all('Table'),'Table'[Project ID]=max('Table'[Project ID])))

1.PNG

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

7 REPLIES 7
v-yetao1-msft
Community Support
Community Support

Hi @Anonymous 

Is this the result you want ?

Ailsa-msft_0-1623734871050.png

Through grouping 'Table'[Project Sub ID] and then count the column rows .

count = CALCULATE(COUNTA('Table'[Project Sub ID]),ALLEXCEPT('Table','Table'[Project Sub ID]))

 

Best Regards

Community Support Team _ Ailsa Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you for your response, sorry I should have clarified more. What I am trying to do is to count the number of subcategories in each project ID and assign that value to each Sub ID. 100 has 2 distinct categories (102A and 102B), so both 102A and 102B will have 2 as value. 103 has 3 distinct categories (103A, 103B, 103C) so 103A, 103B, 103C will have the 3 as value. 

@Anonymous 

please try to create a measure

Measure = CALCULATE(DISTINCTCOUNT('Table'[Project Sub ID]),FILTER(all('Table'),'Table'[Project ID]=max('Table'[Project ID])))

1.PNG

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thank you so much for help! Could you also provide me the explaination of how the measure above works so I could use it as a future reference?

@Anonymous 

Measure = CALCULATE(DISTINCTCOUNT('Table'[Project Sub ID]),FILTER(all('Table'),'Table'[Project ID]=max('Table'[Project ID])))

if we have subject ID, then we can get the corresponding project ID.

FILTER(all table)- remove filters to search the whole table.

then search the project IDs which are the same as the current one.

max or min will return the current project ID





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@Anonymous , Based on what I got,

 

You can create a measure

= count(Table[Value])

and disply  it with project and sub project id in visual

 

or create a table

Summarize(Table, Table[Project], Table[Sub Project], "Count", count(Table[Value]))

Anonymous
Not applicable

@amitchandak,

Thank you for your response. Sorry I put in the wrong output and requirement, I updated so it will do distinct count the number of project id repeated for each project sub id. What should I do in this cases instead?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.