Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I need to load records from another excel file into another based on a range of characters.
The user can enter the first and last into two cells with corrosponding ranges(firstone, lastone)
From these two values, I need to do a power query to load in the data where the customer name is in between these two values.
So, if I have values 0 and D I would want all the customers who's names started with a number, or A, B, C, or D.
I am BRAND NEW to power query and haven't been able to figure this out yet.
Solved! Go to Solution.
Here is one example on how to do this. You can make two parameters in the query editor called FirstLetter and SecondLetter (note these will be case sensitive), and then add a custom column to your query called Keep with this formula. It makes the list of letters between your two parameters and checks if the first letter falls within that range. You then just filter out the "N" columns.
= if List.Contains({FirstLetter..SecondLetter}, Text.Start([LastName],1)) then "Y" else "N"
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Hi @Richard_U ,
As @ mahoneypat's mentioned, you can create two parameters to store your first value and last value, but you can add a query directly like this to filter the column instead of creating a custom column to filter it and remove this column
= Table.SelectRows(#"Changed Type", each List.Contains({firstone..lastone},Text.Start([Name],1)))
In addition, when you create parameters, the type of them should better be text if you want to filter 0..D results, otherwise the query would get type convertion error.
Attached a sample file in the below, hopes it could help.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Richard_U ,
As @ mahoneypat's mentioned, you can create two parameters to store your first value and last value, but you can add a query directly like this to filter the column instead of creating a custom column to filter it and remove this column
= Table.SelectRows(#"Changed Type", each List.Contains({firstone..lastone},Text.Start([Name],1)))
In addition, when you create parameters, the type of them should better be text if you want to filter 0..D results, otherwise the query would get type convertion error.
Attached a sample file in the below, hopes it could help.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Here is one example on how to do this. You can make two parameters in the query editor called FirstLetter and SecondLetter (note these will be case sensitive), and then add a custom column to your query called Keep with this formula. It makes the list of letters between your two parameters and checks if the first letter falls within that range. You then just filter out the "N" columns.
= if List.Contains({FirstLetter..SecondLetter}, Text.Start([LastName],1)) then "Y" else "N"
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.