Forum Discussion
How to calculate Dynamic quarters
- 4 years ago
Hi Anonymous
try this, then put the measure into visual level filter
filterMeasure = VAR _currentMonth = 7 //replace it with month(today()) VAR _currentYear = 2022//replace it with year(today()) VAR _quarter = DIVIDE ( _currentMonth, 3 ) VAR _day = _quarter - QUOTIENT ( _currentMonth, 3 ) VAR _startDate = IF ( _currentMonth < 4, DATE ( _currentYear - 1, 1, 1 ), DATE ( _currentYear, 1, 1 ) ) VAR _endDate = SWITCH ( TRUE (), _currentMonth < 4, DATE ( _currentYear - 1, 12, 31 ), _day <> 0, DATE ( _currentYear, INT ( _quarter ) * 3 + 1, 1 ), _day = 0, DATE ( _currentYear, ( _quarter - 1 ) * 3 + 1, 1 ) ) RETURN IF(MIN('value'[date])<_endDate&&MIN('value'[date])>=_startDate,1,0)2021/10
2022/1
2022/7
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
Thanks for your Reply
I have to show the quaters in columns like Q1 ,Q2,Q3,Q4 now it's oct month means it comes in Q3 so my matrix will show Q1 column ,Q2 column & Q3 column and when Jan month will Start matrix will show Q1,Q2,Q3 Q4 ...and after that when new FY will Start i have to show the only Q1 of this year.
Hi Anonymous
try this, then put the measure into visual level filter
filterMeasure =
VAR _currentMonth = 7 //replace it with month(today())
VAR _currentYear = 2022//replace it with year(today())
VAR _quarter =
DIVIDE ( _currentMonth, 3 )
VAR _day =
_quarter - QUOTIENT ( _currentMonth, 3 )
VAR _startDate =
IF (
_currentMonth < 4,
DATE ( _currentYear - 1, 1, 1 ),
DATE ( _currentYear, 1, 1 )
)
VAR _endDate =
SWITCH (
TRUE (),
_currentMonth < 4, DATE ( _currentYear - 1, 12, 31 ),
_day <> 0,
DATE ( _currentYear, INT ( _quarter ) * 3 + 1, 1 ),
_day = 0,
DATE ( _currentYear, ( _quarter - 1 ) * 3 + 1, 1 )
)
RETURN
IF(MIN('value'[date])<_endDate&&MIN('value'[date])>=_startDate,1,0)
2021/10
2022/1
2022/7
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.