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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
kc_holman
Frequent Visitor

group by a measure column?

I have a table with just year column and because of row level security, some users will see different set of years than the others.

 

I need to add a measure that group the years into groups of 5s when order by years in ascending order.

I created a group_measure with roundup(rownumber/5,0) that groups them into 1s,2s,3s.. etc but I'm having problem using it to get the min(year) max(year) to get the GroupLabel. group_measure doesnt seem to be available in any aggregate/summarize/group function.

 

User1

Year    GroupLabel   group_measure 

1990    1990-2000          1

1992    1990-2000          1

1995    1990-2000          1

1997    1990-2000          1

2000    1990-2000          1

2001    2001-2015          2

2003    2001-2015          2

2006    2001-2015          2
2010    2001-2015          2
2015    2001-2015          2
2017    2017-2019          3
2018    2017-2019          3
2019    2017-2019          3


User2

Year    GroupLabel   group_measure 

1990    1990-2003          1

1992    1990-2003          1

2000    1990-2003          1

2001    1990-2003          1

2003    1990-2003          1
2017    2017-2022          2
2018    2017-2022          2
2021    2017-2022          2
2022    2017-2022          2

1 REPLY 1
Sahir_Maharaj
Super User
Super User

Hello @kc_holman,

 

Can you please try:

GroupLabel = 
VAR CurrentYear = MAX('YourTable'[Year])
VAR GroupMeasure = MAX('YourTable'[group_measure])

VAR MinYearInGroup = MINX(FILTER('YourTable', 'YourTable'[group_measure] = GroupMeasure), 'YourTable'[Year])
VAR MaxYearInGroup = MAXX(FILTER('YourTable', 'YourTable'[group_measure] = GroupMeasure), 'YourTable'[Year])

RETURN
    CONCATENATE(
        MinYearInGroup,
        "-",
        IF(MaxYearInGroup - MinYearInGroup >= 4, MaxYearInGroup, MaxYearInGroup + 4)
    )

Should you require further assistance, please do not hesitate to reach out to me.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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