Forum Discussion

ansa_naz's avatar
ansa_naz
Icon for Continued Contributor rankContinued Contributor
6 years ago
Solved

Advanced Editor - How to run query if current date is NOT within a list of values?

Hi all

I want to run a query in Advanced Editor, only if the current date is NOT one of the following - 1, 5, 10, 15, 20, 25. Otherwise I dont want the query to run. 

 

I have written the below but I am not getting anywhere very fast:

 

let
    Output = if Date.Day (DateTime.LocalNow()) in (1,5,10,15,20,25) then null else 
    let
    Source = PBILifts
in
    #"PBILifts"

 

 

What am I doing wrong?
Cheers for all help

  • My bad.  Please try this approach instead.  I assume PBILifts is an existing query.

     

    let
    Output = if List.Contains({1,5,10,15,20,25}, Date.Day(DateTime.LocalNow())) then null else PBILifts
    in
    Output

4 Replies

  • mahoneypat's avatar
    mahoneypat
    Icon for Microsoft Employee rankMicrosoft Employee

    You have two let and only one in. Add in Output

    Regards

    Pat

     

    • ansa_naz's avatar
      ansa_naz
      Icon for Continued Contributor rankContinued Contributor

      Thanks mahoneypat  I have changed to the below but I still get an error:

       

      let
          if Date.Day (DateTime.LocalNow()) in (1,5,10,15,20,25) then null else 
          Source = PBILifts
      in
          #"PBILifts"

      Any clues please? 

      • mahoneypat's avatar
        mahoneypat
        Icon for Microsoft Employee rankMicrosoft Employee

        My bad.  Please try this approach instead.  I assume PBILifts is an existing query.

         

        let
        Output = if List.Contains({1,5,10,15,20,25}, Date.Day(DateTime.LocalNow())) then null else PBILifts
        in
        Output