Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

How to remove/exclude data from query

Hi there,    I am getting data from folder. In there are multiple excel files. However in each excel I only need a certain date range example for October's excel file, I only need 1-31 October data...
  • Dinesh_Suranga's avatar
    Dinesh_Suranga
    3 years ago

    Anonymous ,

    Hi,

    1 Go to Add Column in top menu.

    2 Click on Custom Column

     

    3 Add following code.
    Please change [source.name] and [DateColumn] as your table.

    if [source.name] = "Excel 1 - All" and Date.MonthName( [DateColumn]) = "May" then "True" else

    if [source.name] = "Excel 2 - All" and Date.MonthName( [DateColumn]) = "June" then "True" else

    if [source.name] = "Excel 3 - All" and Date.MonthName( [DateColumn]) = "July" then "True" else

    if [source.name] = "Excel 4 - All" and Date.MonthName( [DateColumn]) = "August" then "True" else "False"

    Thank you.

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

    No, you can update the formula as below:

    1. If the year of the data column is equal to 2021

    if [source.name] = "Excel 1 - All.xls"

       and Date.Year([DateColumn]) = 2021

       and Date.MonthName([DateColumn]) = "May"

    then "True"
    else "False"

     

    2. If the year of the data column is equal to the year of current date

    if [source.name] = "Excel 1 - All.xls"

       and Date.Year([DateColumn]) = Date.Year(DateTime.LocalNow())

       and Date.MonthName([DateColumn]) = "May"

    then "True"
    else "False"

    Best Regards