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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
ninapetr
Regular Visitor

Count and Aggregate by multiple values

Hello!

So, I'm trying to resolve this, I believe the answer is righ there in front of me, but I just can't assemble my thoughts right... I have the table below and I need 2 measures: 1) Quantity of distinct projects by department and 2) For each Project and department, how many tasks is a owner responsible by?

 

I tried to use "group by", but I did it in two steps: firts, I created a new calculated table, grouping by Project, Task, Department and Owner. Then, I created a measure using "group by" like this: COUNTROWS(GROUPBY("groupstep1","groupstep1[Owner]","groupstep1[Task]","groupstep1[Project]". It actually worked, but I was wondering if there is any way to do this without the firts step. Or any better way....

 

ninapetr_1-1714007195927.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,@ninapetr 

Regarding the issue you raised, my solution is as follows:

1.First I have created the following table and the column names and data are the data you have given:

vlinyulumsft_0-1714025066228.png

2.Secondly to fulfill your two needs I have created two separate measure and my dax function is as follows:

The first measure is grouped by different sectors, and then the number of different items is counted.

 

Measure1 = CALCULATE(DISTINCTCOUNT('group'[Project]),FILTER(ALL('group'),'group'[Department]=MAX('group'[Department])))

 

The second measure filters out different projects, different departments and different owners and then counts the number of tasks.

 

Measure 2 = CALCULATE(COUNTROWS('group'),FILTER(ALL('group'),'group'[Department]=MAX('group'[Department])&&'group'[Project]=MAX('group'[Project])&&'group'[Owner]=MAX('group'[Owner])))

 

3.Here's my final result, which I hope meets your requirements.

vlinyulumsft_0-1714025206789.png

vlinyulumsft_1-1714025215926.png

Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

Best Regards,

Leroy Lu

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

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi,@ninapetr 

Regarding the issue you raised, my solution is as follows:

1.First I have created the following table and the column names and data are the data you have given:

vlinyulumsft_0-1714025066228.png

2.Secondly to fulfill your two needs I have created two separate measure and my dax function is as follows:

The first measure is grouped by different sectors, and then the number of different items is counted.

 

Measure1 = CALCULATE(DISTINCTCOUNT('group'[Project]),FILTER(ALL('group'),'group'[Department]=MAX('group'[Department])))

 

The second measure filters out different projects, different departments and different owners and then counts the number of tasks.

 

Measure 2 = CALCULATE(COUNTROWS('group'),FILTER(ALL('group'),'group'[Department]=MAX('group'[Department])&&'group'[Project]=MAX('group'[Project])&&'group'[Owner]=MAX('group'[Owner])))

 

3.Here's my final result, which I hope meets your requirements.

vlinyulumsft_0-1714025206789.png

vlinyulumsft_1-1714025215926.png

Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

Best Regards,

Leroy Lu

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

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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