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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
maracles
Resolver II
Resolver II

Storing and numerically ordering a values based on lens data - numeric and text values

Hi,

I have a database of lenses and one of their characteristics is 'Focal Length'.

This is measured in mm and the vast majority of values are simply whole numbers. My issue is with zoom lenses which have a variable focal length stored as a text value e.g. 50-100mm.

First question; from a data point of view how should this be stored. If it was single focal lengths I would simply store as whole number, but in what way would I transform my column to make this data most usable? 

Second question; I'm trying to make my tables human readable so ideally if someone wants to produce a table of lenses the zoom's should also be ordered. For example:

If I had the following lenses I would want them ordered as below:

10-50mm
30-70mm
100-200mm

If I order by text however I would get:

10-50mm
100-200mm
30-70mm

And taking this another step up in complexity, if I had a table listing a manufacturer's lenses that produced prime AND zoom lenses I would want them to be show as follows:

- Primes first 
- Zooms second

Example:

Zeiss
   12mm
   16mm 
   24mm

   10-50mm
   30-70mm
   100-200mm

 

Any help would be very much appreciated. 

1 ACCEPTED SOLUTION

Hi @maracles

 

Just use the original text based column.  You can use the "sort by other column" to tell the engine to use the new, numeric column to control the sort order.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

4 REPLIES 4
Phil_Seamark
Employee
Employee

Hi @maracles

 

Why not add some additional columns to your data table.  These can be added using the Query Editor or using DAX.  Split the text up so you have a column that shows the lower bound value as a number (perhaps one for the upper bound).

 

You can then configure your data model sort your original text column by one of the new columns


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Thanks @Phil_Seamark, I had thought about the lower and upper bounds, how would I then tie the original text column to my sort order. 

I had seen a similar suggestion elsewhere but didn't completly see how I could combine them. 

Hi @maracles

 

Just use the original text based column.  You can use the "sort by other column" to tell the engine to use the new, numeric column to control the sort order.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Thanks @Phil_Seamark, just got around to putting that into practice and it (mostly) works nicely. Just some clarification for anyone else reading this, you need to select 'Sort By Column' in the Grid view. Select the column you want to sort, then go to 'Modelling > Sort By Column' and select from there. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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