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
bourne2000
Helper V
Helper V

How to group by in dax ?

Hi

 

I am having below table,

 

Project NameTotal Days to complete
AJim2
BJim3
CJim2
DCarl4
ECarl1
FCarl1
GCarl2

 

I want to group by name and count the project. Then I need to calculate the average days for each name

 

need output as below

 

NameNumber of ProjectsTotal Average days to complete
Jim32.33
Carl42

 

For an example of calculating the Total average days to complete,

 

for Jim, it has three projects and the total days to complete was 7, so the average is 7/3 = 2.33

 

I have more than 50 names and projects, can anyone advise how to do this in DAX?

 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @bourne2000 

 

Number of projects Measure =
COUNTROWS('Table')
 
 
Total Avg days to complete measure =
SUMX ( 'Table', 'Table'[Total Days to complete] ) / [Number of projects Measure]
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

3 REPLIES 3
SanketBhagwat
Solution Sage
Solution Sage

Hi @bourne2000 .

 

To calculate Number Of Projects using GroupBy, you can create a measure using the following DAX and then add it in your table visual;

Number Of Projects = var a =SUMMARIZE(Table1,Table1[Name],"t",COUNT(Table1[Product]))
RETURN SUMX(a,[t]).
 
To calculate Average Days to Complete, create a measure with the help of following DAX
Average Days to Complete = AVERAGE(Table1[Total Days to Complete])
 
You will get your desired result as;
Screenshot (103).png
 Regards,
Sanket Bhagwat.
 
 
 If this post answers your question, then do please mark it as 'Accept as Solution' so that other members could find it quickly.
 
dobregon
Impactful Individual
Impactful Individual

Check if it is possbile that you can repeat the project & name in the same table, depends on your model it could be possible. 

If it is possible you can do a distinctcount of projects, so if it is repetead a project with name it will count only one
https://docs.microsoft.com/es-es/dax/distinctcount-function-dax 

If it is not possible and your table will have unique Project + Name.. you can do a simple Count to count the number of projects per Name. Remember that in your visual you need to add always the Name in order to show the information by name

To calculate the average days, you can do a simple division

DIVIDE(SUM(Days to complete), measure count projects, BLANK())






Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
Jihwan_Kim
Super User
Super User

Hi, @bourne2000 

 

Number of projects Measure =
COUNTROWS('Table')
 
 
Total Avg days to complete measure =
SUMX ( 'Table', 'Table'[Total Days to complete] ) / [Number of projects Measure]
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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.