Forum Discussion
how to apply range between string type data
- 8 months ago
Hello Harish85,
Power BI treats IDs like C240000001 as text, so you can’t use a Between slicer directly.
To apply a numeric range filter, you need to extract the numeric portion and convert it to a number.Option 1: Power Query (Pre-filter before loading)
Go to Transform Data.
Add a Custom Column:
Number.FromText(Text.Middle([ID], 1, Text.Length([ID]) - 1))Rename the column to ID_Number.
Apply a filter:
ID_Number >= 240000001
ID_Number <= 246000216
Load the filtered data into your report.
This is best for large datasets because it filters before import.
Option 2: DAX Calculated Column (Interactive filtering)
In your report view, create a new column:
ID_Num = VALUE(MID([ID], 2, LEN([ID]) - 1))Add a Slicer visual.
Drag ID_Num into the slicer.
Change slicer type to Between.
Set the range: 240000001 to 246000216.
This is best for keeping all data and filtering interactively.
Column Naming Convention (Power BI)
To avoid confusion when using both Power Query and DAX in the same report, I recommend this naming:Power Query → ID_Number (created during data load; used for filtering before import)
DAX → ID_Num (created in report layer; used for interactive filtering)
Outcome Your slicer will show a horizontal slider with two handles, allowing users to filter between any numeric range of IDs.
This works perfectly with either ID_Number (Power Query) or ID_Num (DAX).
This approach ensures you can handle 250k+ rows efficiently while keeping your report interactive and professional.Table VisualBetween-Styled Slicer for ID_NumberBetween-Styled Slicer for ID_Num
Hi Harish85,
if I got you right that you want to do some kind of filtering with the "between" function, then I would do the following based on your screenshot.
Between filtering is only possible with number typed data. Thats why I would extract the numbers from the column and create the filter or selection based on the numbers. There seems to be a logic within the numbers as of your screenshot showing increasing numbers.
Hope this helps!
Best regards!
PS: if this solves your issue or you like it, leave some kudos or mark it as solution.