Forum Discussion
greenlover
4 years agoFrequent Visitor
Compute YTD Value based on Period Selected
Hi Guys, I just need your help in computing the YTD value based on the period selected (Start Date & End Date). Note that the value of the YTD must be minus 1 month from the End Date selected. ...
- 4 years ago
Hi greenlover
Try this measure to find the YTD value:
Measure = VAR _MinD = MIN ( table[date] ) -- find the MIN date in the selected period VAR _MaxD = MAX ( table[date] ) -- find the MAX date in the selected period VAR _MaxD1ML = DATE ( YEAR ( _MaxD ), MONTH ( _MaxD ), 1 ) - 1 -- find the last date of the month before MAX date VAR _MaxD1M = DATE ( YEAR ( _MaxD1ML ), MONTH ( _MaxD1ML ), DAY ( _MaxD ) ) -- find the same day in the last month of the MAX date RETURN CALCULATE ( SUM ( table[column] ), FILTER ( ALL ( table ), table[date] >= _MinD && table[date] <= _MaxD1M ) )If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
VahidDM
4 years agoSuper User
Hi greenlover
Try this measure to find the YTD value:
Measure =
VAR _MinD =
MIN ( table[date] ) -- find the MIN date in the selected period
VAR _MaxD =
MAX ( table[date] ) -- find the MAX date in the selected period
VAR _MaxD1ML =
DATE ( YEAR ( _MaxD ), MONTH ( _MaxD ), 1 ) - 1 -- find the last date of the month before MAX date
VAR _MaxD1M =
DATE ( YEAR ( _MaxD1ML ), MONTH ( _MaxD1ML ), DAY ( _MaxD ) ) -- find the same day in the last month of the MAX date
RETURN
CALCULATE (
SUM ( table[column] ),
FILTER ( ALL ( table ), table[date] >= _MinD && table[date] <= _MaxD1M )
)
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/