Forum Discussion
cristianj
3 years agoHelper IV
What am i doing wrong
Hello i have this messure, the ideea is to show value from 7 days back, if i select a date, from that date , if nothing is selected from today - 7 so this is tha data which is working for the today...
- 3 years ago
Hi cristianj, your calculation looks to be overcomplicated... Is there a spicific reason why you wrote it in this way? You can achieve the similar result much simplier:
Sales 7 days before = VAR _CurrentDate = SELECTEDVALUE( CalendarTable[Date] ) //we need to remember the currently selected date, because we0ll overwrite it with Calculate() later RETURN CALCULATE( SUM( Sales[Sales] ), CalendarTable[Date] = _CurrentDate - 7 )Let me know if it works or if I misunderstood your question.
cristianj
3 years agoHelper IV
Thank you werry much, with your help i change the formula and now it is working
Selected Day -7 Beta =
var currentDate=if(ISFILTERED('Date'[DateDispaly])=TRUE(),SELECTEDVALUE('Date'[Date]),TODAY())
return
calculate(
sum('Orders Sent last 31 days'[Valoare Comenzi Plecate de la Flip (EUR)]),
'Date'[Date]=currentDate-7)
Do you have any ideea what thas not working before?
Thank you again
Sergii24
3 years agoSuper User
I believe there is something related to Context Transition - Understanding context transition in DAX - SQLBI. Unfortunately I can't dedicate more time to debug your code but you can do so by yourself after carefully reading this article 🙂