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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Dynamic grouping of years based on slicer

Dear BI community

I have a data set like this which shows the built year of every ship in the period from 2000-2024. 

Built yearShip

2010

A
(blank)B
2019BB

2022

C
2023Dr
2024

E

 

I need to make a table visual that shows this, where there is a grouping of earlier years, which includes ships without data on built year:

Built yearShips
<2023 and blank (GROUP)4
20231
20241

 

BUT I also need a slicer on the page so the user can choose when the grouping starts based on built year. So e.g. the user could also set the group year to begin at 2022 (instead of 2023 as above) so it would look like this instead:

Built yearShips
<2022 and blank (GROUP)3
20221
20231
20241


I hope it makes sense and somebody can help me 🙂

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @Anonymous 

Thanks for lbendlin's concern about this issue.

 

I am glad to help you.

 

If you want to get a dynamic year based on Slicer, then you can only use Measure. but Measure gets a value, not an actual column, so it can't dynamically group the ships based on the obtained Year. 

  

Maybe you can refer to my solution: 

First you need New table for Slicer filtering: 

vfenlingmsft_1-1724658608779.png

 

SlicerTable = 
GENERATESERIES ( MIN ( Table1[Built year] ), MAX ( Table1[Built year] ), 1 )

 

Create a Measure for grouping: 

GroupYear = 
VAR SelectedYear =
    SELECTEDVALUE ( 'SlicerTable'[Year] )
RETURN
    IF (
        ISBLANK ( MAX ( 'Table1'[Built year] ) )
            || MAX ( 'Table1'[Built year] ) < SelectedYear,
        "<" & SelectedYear & " and blank (GROUP)",
        MAX ( 'Table1'[Built year] )
    )

 

Create a Measure for calculating ships: 

Ships = 
VAR _Year =
    MAX ( 'Table1'[Built year] )
VAR _selectedYear =
    MAX ( 'SlicerTable'[Year] )
RETURN
    IF (
        _Year < _selectedYear,
        CALCULATE (
            COUNTROWS ( 'Table1' ),
            FILTER ( ALL ( Table1 ), [Built year] < _selectedYear )
        ),
        COUNTROWS ( 'Table1' )
    )

 

Result: 

vfenlingmsft_2-1724658832421.png

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
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

2 REPLIES 2
Anonymous
Not applicable

Hi, @Anonymous 

Thanks for lbendlin's concern about this issue.

 

I am glad to help you.

 

If you want to get a dynamic year based on Slicer, then you can only use Measure. but Measure gets a value, not an actual column, so it can't dynamically group the ships based on the obtained Year. 

  

Maybe you can refer to my solution: 

First you need New table for Slicer filtering: 

vfenlingmsft_1-1724658608779.png

 

SlicerTable = 
GENERATESERIES ( MIN ( Table1[Built year] ), MAX ( Table1[Built year] ), 1 )

 

Create a Measure for grouping: 

GroupYear = 
VAR SelectedYear =
    SELECTEDVALUE ( 'SlicerTable'[Year] )
RETURN
    IF (
        ISBLANK ( MAX ( 'Table1'[Built year] ) )
            || MAX ( 'Table1'[Built year] ) < SelectedYear,
        "<" & SelectedYear & " and blank (GROUP)",
        MAX ( 'Table1'[Built year] )
    )

 

Create a Measure for calculating ships: 

Ships = 
VAR _Year =
    MAX ( 'Table1'[Built year] )
VAR _selectedYear =
    MAX ( 'SlicerTable'[Year] )
RETURN
    IF (
        _Year < _selectedYear,
        CALCULATE (
            COUNTROWS ( 'Table1' ),
            FILTER ( ALL ( Table1 ), [Built year] < _selectedYear )
        ),
        COUNTROWS ( 'Table1' )
    )

 

Result: 

vfenlingmsft_2-1724658832421.png

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

Teach your users how to operate the Filter panel. They can formulate their filter choices there.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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