Forum Discussion

MiaSunny's avatar
MiaSunny
Icon for Helper I rankHelper I
2 years ago
Solved

Filter SQL view data in Power Query

I have a sql view from other department that I cannot check the code or modify only select permission.  (the best practice is filtering and shaping the data from SQL to fit the needs while i have no...
  • Claude_Xu's avatar
    2 years ago

    Hi, it looks like the view in the database uses a varchar column to hold date type, and string literal 'Not Provided' is put in the column for missing case, instead of using a date type column with null allowed. If that's the case, to fix the issue in the source is the best solution.

     

    If that's impossbile for whatever reason, you can load the data and do cleaning & transformation with M.

    1. Load all the data, including those 'Not Provided' records.
    2. Use Table.SelectRows to select the rows you need. One dummy solution is to define a function to check that date column and only returns true if the column contains a date value text, and that date text is greater than 20240630

    That't my two cents. You may have another implementation for loading and filtering the data with M.