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

Grouping with gaps

Hello,
I am trying to group data with gaps inside them. This is a sample of my data:

 

distance fromdistance to built year Type road Living area ZoneState 
0101990AlleyYesAGood
10151990AlleyYesAGood
20251995AlleyYesAGood
30601995Street ABad
60711990  ABad
1001202020  A 
3003701995HighwayNo B 
3704002020HighwayNo B 

I want to group my values by 'distnace from' and 'distance to' in a table. I have defined field paramters that the user would choose to display on the table:

 

JCG99_0-1718870677153.png

The problem is that it doesn't not diaply the right data when there are gaps. Take for instance the case when I display the built year.

This is what I get by using min/max for the distance from and distance to (renamed measure_from/measure_to, as it is now a measure):

 

 Measure_fromMeasure_tobuilt year 

0711990
203701995
1004002020

And I should be getting this:

 

Measure_fromMeasure_tobuilt year 

0151990
20251995
30601995
60711990
1001202020
3003701995
3704002020
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @JCG99 

Please try the following DAX:

Min from = 
VAR _selectyear =  SELECTEDVALUE('Table'[built year ])
VAR _selecttype = SELECTEDVALUE('Table'[Type road ])
RETURN
MINX(FILTER(ALL('Table'),'Table'[built year ] = _selectyear && 'Table'[Type road ]=_selecttype),'Table'[distance from])
Max to = 
VAR _selectyear =  SELECTEDVALUE('Table'[built year ])
VAR _selecttype = SELECTEDVALUE('Table'[Type road ])
RETURN
MAXX(FILTER(ALL('Table'),'Table'[built year ] = _selectyear && 'Table'[Type road ]=_selecttype),'Table'[distance to ])

 

Result:

vjialongymsft_0-1718933994104.png

 

 

 

 

Best Regards,

Jayleny

 

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

Thanks for the answer. The grouping works good when the column buitl year and type road are selected, but not in other configuration. 

For instance, when only built year is selected, I get this result: 

JCG99_0-1719478707867.png

However, I expect to get all type of road:

0 -> 25 Alley

30 -> 60 Street 

60 -> 120 /

300 -> 400 Highway

 

Anonymous
Not applicable

Hi @JCG99 

Please try the following DAX:

Min from = 
VAR _selectyear =  SELECTEDVALUE('Table'[built year ])
VAR _selecttype = SELECTEDVALUE('Table'[Type road ])
RETURN
MINX(FILTER(ALL('Table'),'Table'[built year ] = _selectyear && 'Table'[Type road ]=_selecttype),'Table'[distance from])
Max to = 
VAR _selectyear =  SELECTEDVALUE('Table'[built year ])
VAR _selecttype = SELECTEDVALUE('Table'[Type road ])
RETURN
MAXX(FILTER(ALL('Table'),'Table'[built year ] = _selectyear && 'Table'[Type road ]=_selecttype),'Table'[distance to ])

 

Result:

vjialongymsft_0-1718933994104.png

 

 

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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