Forum Discussion
JMS1985
5 years agoFrequent Visitor
Calculate future values
Hello, I have a table with vehicles (each line is an individual vehicle) and each vehicle has a date that indicates the moment the vehicle is being sold and wont be in my fleet anymore. Pl...
Anonymous
5 years agoNot applicable
Hi JMS1985
I build a sample to have a test.
Firstly let‘s build a calendar table as below.
Calendar =
VAR _T1 = ADDCOLUMNS(CALENDARAUTO(),"Year",YEAR([Date]),"MONTH",MONTH([Date]),"MONTHNAME",FORMAT([Date],"MMMM"),"YEARMONTH",YEAR([Date])*100+MONTH([Date]),"WEEKNUM",WEEKNUM([Date],2))
VAR _T2 = ADDCOLUMNS(_T1,"RANK",RANKX(_T1,[YEARMONTH],,ASC,Dense))
RETURN
_T2
Build a relationship between two tables by Date columns.
Then build measures to calcualte the count of next week, month,year.
Next WEEK Count =
CALCULATE(COUNT('Sample'[Plate number]),FILTER('Calendar','Calendar'[Year] = YEAR(TODAY()) && 'Calendar'[WEEKNUM]= WEEKNUM(TODAY(),2)+1))Next Month Count =
VAR _CURRANK = CALCULATE(MAX('Calendar'[RANK]),FILTER('Calendar','Calendar'[Date] = TODAY()))
RETURN
CALCULATE(COUNT('Sample'[Plate number]),FILTER('Calendar','Calendar'[RANK] = _CURRANK+1))Next YEAR Count =
CALCULATE(COUNT('Sample'[Plate number]),FILTER('Calendar','Calendar'[Year] = YEAR(TODAY())+1 ))
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- JMS19855 years agoFrequent Visitor
Hello Anonymous thank you for your help.
What I actually need is to know the number of vehicles remaining, not the number of vehicles leaving.
So if today (monday) I have 8 cars and tomorrow 2 cars leave, Ill have 6 cars remaining.
I still can´t find the way to calculate this