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

group by in a measure

I have 2 problems about this table.

 

power bi help 3.JPG

 

This is a heirarchy like this:

R (grand parent) > X (parent) > A (child), B (child)

 (grand parent) > Y (parent) > C (child), D (child), E (child)

 

Problem 1: I need to find the latest date among all the children of a parent, grouped by parent. Meaning;

X   -  which child has the latest date? 1-Feb-18

Y - which child has the latest date? 1-May-18

 

Problem 2: I need to find total work done by all the children of a parent, grouped by parent. Meaning;

X   -  total work done by children? 5

Y - total work done by children? 9

 

If these can be new columns, it will be great.

 

Thanks

2 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

 

Try this calculated column formula

 

=IF(Data[Type]="Parent",CALCULATE(MAX(Data[Date]),FILTER(Data,Data[Parent Name]=EARLIER(Data[Name]))),BLANK())

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

v-lili6-msft
Community Support
Community Support

hi, @Anonymous

You could use EARLIER Function to create these two columns

Problem 1 = IF(Data[Type]="Parent",CALCULATE(MAX(Data[Date]),FILTER(Data,Data[Parent Name]=EARLIER(Data[Name]))),BLANK())
Problem 2 = IF(Data[Type]="Parent",CALCULATE(SUM(Data[work done]),FILTER(Data,Data[Parent Name]=EARLIER(Data[Name]))),BLANK())

Result:

14.JPG

 

Best Regards,

Lin

 

Community Support Team _ Lin
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

4 REPLIES 4
v-lili6-msft
Community Support
Community Support

hi, @Anonymous

You could use EARLIER Function to create these two columns

Problem 1 = IF(Data[Type]="Parent",CALCULATE(MAX(Data[Date]),FILTER(Data,Data[Parent Name]=EARLIER(Data[Name]))),BLANK())
Problem 2 = IF(Data[Type]="Parent",CALCULATE(SUM(Data[work done]),FILTER(Data,Data[Parent Name]=EARLIER(Data[Name]))),BLANK())

Result:

14.JPG

 

Best Regards,

Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks so much. That solved my problem instantly. You are a genius!

Ashish_Mathur
Super User
Super User

Hi,

 

Try this calculated column formula

 

=IF(Data[Type]="Parent",CALCULATE(MAX(Data[Date]),FILTER(Data,Data[Parent Name]=EARLIER(Data[Name]))),BLANK())

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Thanks so much. That solved my problem instantly. You are a genius!

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.