Forum Discussion
Plot a graph between two dates
- 4 years ago
maxduff59 if you will create a measure like:
MEASURE =
VAR _x_days_before_date = [Your Date x days before Measure]
VAR _date = [your the date of the day Measure]
RETURN
CALCULATE([Your value], DATESBETWEEN('Date Table'[Date], _x_days_before_date, _date]
You would get the y values only for those dates, everything outside will be blank and not presented on the chart and axis will start from your desired start to end.
maxduff59 if you will create a measure like:
MEASURE =
VAR _x_days_before_date = [Your Date x days before Measure]
VAR _date = [your the date of the day Measure]
RETURN
CALCULATE([Your value], DATESBETWEEN('Date Table'[Date], _x_days_before_date, _date]
You would get the y values only for those dates, everything outside will be blank and not presented on the chart and axis will start from your desired start to end.
I will try that, thank you. I just have a little question, why do I need to redefine my date measures through variables ?
Moreover, what is the first term of the CALCULATE function [YOUR VALUE] ?
- SpartaBI4 years agoCommunity Champion
maxduff59 variables are always good thing to use for code readability and better performance. In some cases you must use them cause sometimes if you put your measures inside another calculate filter argument you might not get what you want.
Of course you can't use, btw, variables as something to put in the 1st argument of calculate cause they are already been executed.
Actually, yesterday came out a cool video I recommend to watch:
https://www.youtube.com/watch?v=NbbE39gwVVoPlease don't forget to accept the relevant messages as a solution for community visibility. P.S. Check out my showcase report - got some high level stuff there. Sure you will find there a lot of cool ideas. Please give it a thumbs up over there if you liked it 🙂 https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543
- maxduff594 years agoHelper II
Thanks for the explications, I just don't understand which term do I need to put first in the CALCULATE function...
- SpartaBI4 years agoCommunity Champion
you put there an aggregation expression ususally, and you can also call a measure instead. The think I meant that in this case you can't use a var before it and call it inside. But I think the video explains it better.
Let me know that is what you meant.