Forum Discussion
Sum by weeknumber
Hi guys,
I'm trying to create a column based on last week value with DAX, I already create weeknumber column. I tryed this code :
lastweek value = CALCULATE(SUMX(Tabela,Tabela[Insight]),FILTER(ALL(Tabela),Tabela[weeknumber]-1))
But the column shows the sum of all table, and I want something like this:
| insight | weeknumber | lastweek value |
| 1 | 10 | 3 |
| 1 | 10 | 3 |
| 1 | 10 | 3 |
| 1 | 9 | 1 |
| 1 | 9 | 1 |
| 1 | 9 | 1 |
| 1 | 8 | 0 |
| 0 | 8 | 0 |
- Anonymous6 years ago
Hi gizattos ,
You can use EARLIER() function
Column = CALCULATE(SUM('Table'[insight]),FILTER('Table','Table'[weeknumber]=EARLIER('Table'[weeknumber])-1))Best Regards,
Jay
Community Support Team _ Jay Wang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
9 Replies
- ryan_mayu
Super User
Please try the DAX below to see if this works for you
lastweek value = VAR d = max(tabela[weeknumber]) RETURN CALCULATE(SUMX(Tabela,Tabela[Insight]),FILTER(ALL(Tabela),Tabela[weeknumber]=d-1))- gizattosRegular Visitor
didn't work, now i have the sum of a specific week repeated for all rows.
- AnonymousNot applicable
Hi gizattos ,
You can use EARLIER() function
Column = CALCULATE(SUM('Table'[insight]),FILTER('Table','Table'[weeknumber]=EARLIER('Table'[weeknumber])-1))Best Regards,
Jay
Community Support Team _ Jay Wang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.