Forum Discussion
GustavoBorges
3 years agoFrequent Visitor
DATEDIFF returning incorrect value inside a DATEADD function
I want to plot some measurements on a line chart. Measures refer to the period selected in a filter on the page. Then the measure referring to the value of the selected date is plotted, the measure...
v-chenwuz-msft
3 years agoCommunity Support
Hi GustavoBorges ,
I think the var lead to the wrong result. Please note that the var will ignore any filters when you do some filter to it under "return".
Change the Dias_entre_datas like this:
Dias_entre_datas =
DATEDIFF(LASTDATE(dCalendario[Date]), PREVIOUSDAY(FIRSTDATE(dCalendario[Date])), DAY)
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
GustavoBorges
3 years agoFrequent Visitor
Incidentally, if I multiply the [Dias_entre_datas] by "-1" inside the DATESBETWEEN, it works by inverting from "-1" to "1", as in the image below
Criados P-1 = CALCULATE(
[total_negocios],
DATESBETWEEN(dCalendario[Date], FIRSTDATE(DATEADD(dCalendario[Date], -1*[Dias_entre_datas], DAY)), FIRSTDATE(DATEADD(dCalendario[Date], -1*[Dias_entre_datas], DAY)))
)