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

Power Query : Min of group of values

Hello everyone,

 

I have this kind of table :

Code - Value

N1 - 1

N1 - 4
N1 - 7

N2 - 3

N2 - 5

N2 - 5

N3 - 7

N3 - 9

 

I want to filter data to have the minimum VALUE for each CODE like this :

N1 - 1

N2 - 3

N3 - 7

 

How to do it in a query in Power Query ?


Thank you.

2 ACCEPTED SOLUTIONS
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

You can use Group By as per below.

 

image.png

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

MFelix
Super User
Super User

Hi @Anonymous ,

 

You need to go to the Transform  part then Group by, select the Code as the Group by column and in the operation select Minimum of the column value:

 

Group_by.png


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

8 REPLIES 8
MFelix
Super User
Super User

Hi @Anonymous ,

 

You need to go to the Transform  part then Group by, select the Code as the Group by column and in the operation select Minimum of the column value:

 

Group_by.png


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

Thank you for your answers @Mariusz and @MFelix 

 

The problem is that when I do this "Group by", my others columns disappears.

 

BEFORE

01.PNG

 

AFTER

02.PNG

Hi @Anonymous ,

 

Do you want to keep all the other column and on the Value repeat the minimum value?


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix, yes, how can this be done? I want to keep same number of records and repeat the minimum value for each group 

Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Yes absolutely. In the sample example given above, i would like to see the following output.

Input:

N1 - 1

N1 - 4
N1 - 7

N2 - 3

N2 - 5

N2 - 5

N3 - 7

N3 - 9

 

Output:

 

N1 - 1 - 1

N1 - 4 - 1
N1 - 7 - 1

N2 - 3 - 3

N2 - 5 - 3

N2 - 5 - 3

N3 - 7 - 7

N3 - 9 - 7

Hi @Anonymous 

 

Please see the attached file with a solution.

This will involve some M scripting, so let me know if you need help.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

You can use Group By as per below.

 

image.png

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

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.

Top Solution Authors