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
HugoCExtA
Regular Visitor

Group by specific condition

Hello,

 

I have a table that I'd like to group by with a specific condition, the condition is : each time there is a 1 in a colum I'd like to group until there is another 1 in the same column. (Not sure it is very clear so I made a picture of what I'd like).

 

Capture.JPG

 

I'm not even sure it is possible with Power BI, but still any advice would be nice.

 

Thanks in advance.

1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

In the query editor just add an index column first. Then multiply that with Type. Replace 0 by null and fill down values.

That will allocate the same number to each row in the group but a different number per group.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

2 REPLIES 2
ImkeF
Super User
Super User

In the query editor just add an index column first. Then multiply that with Type. Replace 0 by null and fill down values.

That will allocate the same number to each row in the group but a different number per group.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Thanks, it worked ! Did not know the fill function 🙂

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.