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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Aggregate amount of days in column to groups

Hi,

 

I have a calculated column of days an event is going on. The list is anything between 0 to 200. I want to aggregate that to groups like 0-5 Days, 6-10 Days, 11-30 Days, 31-60 Days, 61-90 Days and Over 90 Days. So anything between 0 and 5 would get the group 0-5 Days, etc.  I want to use that to calculate how many events are taking longer than 0-5 Days for example:

 

Example of the visual I'l trying to create: https://ibb.co/XjKqLZp 

 

Thank you in advance, 

Frank

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Anonymous 

 

you can create a column.

day group = SWITCH(TRUE(),'Table (2)'[day]<=5,"0-5days",'Table (2)'[day]<=10,"6-10days",'Table (2)'[day]<=30,"11-30days",'Table (2)'[day]<=60,"31-60days",'Table (2)'[day]<=90,"61-90 days",">90days")

1.PNG

Then create a measure

count = COUNTX(FILTER('Table (2)','Table (2)'[day group]="0-5days"),'Table (2)'[day])

 2.PNG





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

Proud to be a Super User!




View solution in original post

4 REPLIES 4
ryan_mayu
Super User
Super User

@Anonymous 

 

you can create a column.

day group = SWITCH(TRUE(),'Table (2)'[day]<=5,"0-5days",'Table (2)'[day]<=10,"6-10days",'Table (2)'[day]<=30,"11-30days",'Table (2)'[day]<=60,"31-60days",'Table (2)'[day]<=90,"61-90 days",">90days")

1.PNG

Then create a measure

count = COUNTX(FILTER('Table (2)','Table (2)'[day group]="0-5days"),'Table (2)'[day])

 2.PNG





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

Proud to be a Super User!




Anonymous
Not applicable

This worked after I added a space between the condition and the value <=5 , "0-5 Days" ....

Anonymous
Not applicable

Thank you for the suggestion. I tried im getting this error: Unexpected expression '"0-5days"'. (I changed the table and column name to the correct)

Icey
Community Support
Community Support

Hi @Anonymous ,

 

Please share some screenshots or a dummy .pbix file, so we can help you find the cause of the problem. Please remove sensitive information.

 

 

Best Regards,

Icey

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.