Forum Discussion

LilMango82's avatar
LilMango82
New Member
2 years ago

Power BI Table Filter >= Last week

Hi,

 

I have a column labelled Install_dates. 

 

I want to filter the column at load from last week's dates Monday onwards to today.

 

Can someone help please. 

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi LilMango82 - thank you for your question.  You should consider using the following functions in column filter:

    The combination of these functions will filter for last week and this week upto today.

    = Table.SelectRows(
          #"Changed Type", 
          each 
             (  Date.IsInPreviousWeek([Dates]) 
             or Date.IsInCurrentWeek([Dates]) ) 
             and [Dates] <= Date.From(DateTime.FixedLocalNow()) 
    )

     

  • Thank you Daryl. 

     

    I've just stared using Power BI. 

     

    So, sorry if I sound a bit clueless. 

     

    If I am correct, Step 1 filter by last week. 

    Step 2, paste the code and then change "Change Type" to "Filtered Row" as the step would apply a filter. 

    • Anonymous's avatar
      Anonymous
      Not applicable

      No worries LilMango82 - you need to learn to understand the structure of the M formulas.  #"Change Type" is a reference to the previous applied step.  If this was the second step the first is normally called "Source".   If your previous step is called #"Filtered Row", then yes.

      Note the structure of the formula:

      Table.SelectRows is the function name for filtering (i.e. you are selecting rows)
      #"Change Type" is the table to be filter or rows selected from.
      each - this reflects that the following formula is applied to each row in the #"Change Type" table
      [Dates] this was the name of the column that formula was applied to in the #"Change Type" table.

      Date.IsInPreviousWeek is another formula to return True or False for the each row in the Table.