Forum Discussion
Anonymous
2 years agoNot applicable
DAX Query: Relative difference visible previous day
Hi I have the following query table yet (i'm not interested in a Table or Matrix visual): How can i get a new column with the relative difference of one of the visible day with the p...
- 2 years ago
Hi Anonymous
You can use the OFFSET function.
Here is an example:
Test = VAR SummarizedTable = SUMMARIZE ( 'Table Principale', [Date Commande], "Somme Cash-Flow", SUM ( 'Table Principale'[Prix total avec rabais] ) ) VAR AddPrevious = ADDCOLUMNS ( SummarizedTable, "Somme Cash-Flow Previous", -- Guaranteed to be a single row SELECTCOLUMNS ( OFFSET ( -1, SummarizedTable, ORDERBY ( 'Table Principale'[Date Commande] ) ), [Somme Cash-Flow] ) ) RETURN AddPreviousI would also recommend changing SUMMARIZE (...) to ADDCOLUMNS ( SUMMARIZE (... ), ... ), but that's a best practice suggestion rather than a necessity here.
Regards
OwenAuger
2 years agoSuper User
Hi Anonymous
You can use the OFFSET function.
Here is an example:
Test =
VAR SummarizedTable =
SUMMARIZE (
'Table Principale',
[Date Commande],
"Somme Cash-Flow", SUM ( 'Table Principale'[Prix total avec rabais] )
)
VAR AddPrevious =
ADDCOLUMNS (
SummarizedTable,
"Somme Cash-Flow Previous",
-- Guaranteed to be a single row
SELECTCOLUMNS (
OFFSET ( -1, SummarizedTable, ORDERBY ( 'Table Principale'[Date Commande] ) ),
[Somme Cash-Flow]
)
)
RETURN
AddPrevious
I would also recommend changing SUMMARIZE (...) to ADDCOLUMNS ( SUMMARIZE (... ), ... ), but that's a best practice suggestion rather than a necessity here.
Regards
- Anonymous2 years agoNot applicable
Thanks a lot! That works like a charm.