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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Creating a new range column in Power Query

Hi,
 
I'm currently working with some survey data in Power BI and struggling to creating a new range column based on two other columns. The collection of age data has changed at some point through the years from exact age to an age range and is not aligned (some rows has exact age, some has age range, some has both and some neither). I'm therefore interested in aligning and unifying the age data in a new column similar to the age range column. I've created min value and max value columns to hopefully do this in a sorta 'lookup'-type fashion. 
 
So, its the yellow column [New Age] I would like to create and to be dynamic if other ranges were to be added later - with logic somewhat like this:
if [nyaldgrp] > 0 then [nyaldgrp]
else if [alder] >= [Min_Value] and <= [Max_Value] then [Age_BK]
 
tables.PNG
 
 
 
 
 
 
 
I hope you'll able to help
1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Your Age Dimension table has all the unique entries, right? Here is one way, added one row to show the result

 

Vera_33_1-1626237241452.png

 

 

(x)=> if x[nyaldrp]>0 then x[alder]
else dimAge[Age_BK]{ List.PositionOf(dimAge[Custom],List.Select(dimAge[Custom], each List.Contains(_,x[alder])){0})}?

 

Added one Custom column in dimAge 

Vera_33_2-1626237309947.png

 

 

View solution in original post

1 REPLY 1
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Your Age Dimension table has all the unique entries, right? Here is one way, added one row to show the result

 

Vera_33_1-1626237241452.png

 

 

(x)=> if x[nyaldrp]>0 then x[alder]
else dimAge[Age_BK]{ List.PositionOf(dimAge[Custom],List.Select(dimAge[Custom], each List.Contains(_,x[alder])){0})}?

 

Added one Custom column in dimAge 

Vera_33_2-1626237309947.png

 

 

Helpful resources

Announcements
FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.