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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ninapetr
New Member

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
v-linyulu-msft
Community Support
Community Support

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
v-linyulu-msft
Community Support
Community Support

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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