Forum Discussion

Creative_tree88's avatar
1 year ago
Solved

Flag to show only complete weeks

H - I have data which is refreshed daily, but there is an element of our app which shows data on a weekly basis (Monday to Sunday).  If the app is refreshed on, say, the Tuesday, I don't want any of this 'partial' week to show.  I only just want to show complete weeks, not partial weeks.

 

I have a date table, so just really need some ideas as to how to create this, either in Power Query, or as a DAX expression?

 

Many thanks!

  • You could create a column like

    Before Current Week =
    VAR StartCurrentWeek =
        TODAY () - WEEKDAY ( TODAY (), 2 ) + 1
    VAR Result = 'Date'[Date] < StartCurrentWeek
    RETURN
        Result
    
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi All,
    Firstly  johnt75 thank you for your solution!
    And Creative_tree88 ,According to your question, you can also do it in power query to keep the complete week, we first calculate the weekend date for each row, then in another column we use to mark the week as complete or not, and finally in desktop, we filter the data by IsCompleteWeek column to show only the data with value 1.

     

    EndOfWeek = Date.EndOfWeek([Date], Day.Sunday)
    
    if Date.From(DateTime.LocalNow()) >= [EndOfWeek] then 1 else 0

     

    Hope it helps!

    Best regards,
    Community Support Team_ Tom Shen

    If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

     

2 Replies

  • You could create a column like

    Before Current Week =
    VAR StartCurrentWeek =
        TODAY () - WEEKDAY ( TODAY (), 2 ) + 1
    VAR Result = 'Date'[Date] < StartCurrentWeek
    RETURN
        Result
    
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi All,
    Firstly  johnt75 thank you for your solution!
    And Creative_tree88 ,According to your question, you can also do it in power query to keep the complete week, we first calculate the weekend date for each row, then in another column we use to mark the week as complete or not, and finally in desktop, we filter the data by IsCompleteWeek column to show only the data with value 1.

     

    EndOfWeek = Date.EndOfWeek([Date], Day.Sunday)
    
    if Date.From(DateTime.LocalNow()) >= [EndOfWeek] then 1 else 0

     

    Hope it helps!

    Best regards,
    Community Support Team_ Tom Shen

    If this post helps then please consider Accept it as the solution to help the other members find it more quickly.