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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors