Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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 , or any other selection
Solved! Go to Solution.
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.
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.
Thank you werry much, with your help i change the formula and now it is working
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 🙂
Thank you i will change and try,
i write it in such way, because if is nothing selected, it has to use the today as a starting point, but i try and let you know
I see, here is the updated code (read comment for more details on it):
Sales 7 days before =
VAR _CurrentDate =
SELECTEDVALUE(
CalendarTable[Date],
MAXX( ALL( CalendarTable[Date] ),
TODAY()
)
)
//we need to remember the currently selected date, because we'll overwrite it with Calculate() later. SELECTEDVALUE() return only 1 value, so if multiple dates are selected, we need to return an alternative result - the second argument of the formula. In this case I used Today() to obtain today's date, but you can replace it with any other date, for instance absolute MAX of CalendarTable. Simply replace the code of variable from the above with the following:
/*
VAR _CurrentDate =
SELECTEDVALUE(
CalendarTable[Date],
MAXX(
ALL( CalendarTable[Date] ),
CalendarTable[Date]
)
)
*/
RETURN
CALCULATE(
SUM( Sales[Sales] ),
CalendarTable[Date] = _CurrentDate - 7
)
and i try to make it a messure, because i need to display the current value(today or the selected one), current value 7 days back and current value 14 days back
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
78 | |
76 | |
53 | |
37 | |
31 |
User | Count |
---|---|
101 | |
56 | |
51 | |
45 | |
40 |