Forum Discussion

User7664's avatar
User7664
Icon for Helper I rankHelper I
5 years ago
Solved

Adding a custom 'MAXIFS' column on a calculated table

Hi

I have a calculated table in my model which contains the dates from another table. Within that table is a week number which looks at the MAX date in the table and then counts back 7 days. The 7 biggest days in the table are therefore week -1, the next 7 are week -2 etc.

I am trying to add a new column which will show the max date relative to the week number. In the screenshot below every row from week -8 would show 17 Jan 2021, for week -7 it would show 24 Jan 2021 etc.

In excel i would run MAXIFS(DATE,WeekNumber,<the cell along side>) or similar.

You can see the attempt i've made but with little success.

Any guidance would be swell

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi User7664 

     

    Try it

    Column = 
    VAR CurWeek = ABS('Table'[Week Number])
    RETURN
    MAXX(FILTER('Table',ABS('Table'[Week Number])= CurWeek),'Table'[Date])

     

5 Replies

  • Could this be cause i use roundup on my week number calculation?

  • No, im not trying to find the end of the week. The end of the week will always be the last day in the query that this table is generated from. The End of the week can often be a tuesday or a thursday. The -1 indicates all the days part of that week, and the -2 are all the days part of the 2nd week back. I just need to know what the last day in -1 is and the last day in -2 is etc.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi User7664 

     

    Try it

    Column = 
    VAR CurWeek = ABS('Table'[Week Number])
    RETURN
    MAXX(FILTER('Table',ABS('Table'[Week Number])= CurWeek),'Table'[Date])