Forum Discussion
YoY Growth Card
- 1 year ago
Thank you for all the valuable suggestions.
I was able to work it out.
Included the solution below for everyone's reference.
Also, sharing the screenshot of the card with the final outputYoY_OrderFlow% = VAR _currentDate = TODAY() VAR _currentYear = IF( MONTH(_currentDate) >= 4, YEAR(_currentDate) + 1, YEAR( _currentDate)) VAR _currentFY = "FY-" & _currentYear RETURN CALCULATE( VAR _cy = [TotalOrderedQuantity] VAR _ly_startDate = EDATE( MIN( Calendar_Table[Date]), -12) VAR _ly_endDate = EOMONTH( MAX( OrderData[ReceiveDate] ), -12) VAR _ly = CALCULATE( [TotalOrderedQuantity], DATESBETWEEN( Calendar_Table[Date], _ly_startDate, _ly_endDate ), REMOVEFILTERS( Calendar_Table[FY_Year] ) ) VAR isValidForGrowth = NOT ISBLANK( _cy ) && NOT ISBLANK( _ly ) && _ly <> 0 VAR _growth = IF( isValidForGrowth, DIVIDE( _cy, _ly) - 1) RETURN _growth, FILTER( ALL( Calendar_Table[FY_Year] ), Calendar_Table[FY_Year] = _currentFY ) )
If you need to dynamically determine the current financial year based on today's date, you can use the following approach:
DAX
VAR CurrentDate = TODAY()
VAR CurrentFY =
IF(
MONTH(CurrentDate) >= 4,
YEAR(CurrentDate) & "/" & YEAR(CurrentDate) + 1,
YEAR(CurrentDate) - 1 & "/" & YEAR(CurrentDate)
)
VAR PreviousFY =
IF(
MONTH(CurrentDate) >= 4,
YEAR(CurrentDate) - 1 & "/" & YEAR(CurrentDate),
YEAR(CurrentDate) - 2 & "/" & YEAR(CurrentDate) - 1
)
VAR _CY =
CALCULATE(
[Total Order Volume],
FILTER(
Calendar_Table,
Calendar_Table[FY_Year] = CurrentFY
)
)
VAR _LY =
CALCULATE(
[Total Order Volume],
FILTER(
Calendar_Table,
Calendar_Table[FY_Year] = PreviousFY
)
)
VAR _Check = _CY && _LY
VAR _Growth = IF(_Check, DIVIDE(_CY, _LY) - 1)
RETURN
_Growth
- JajatiDev1 year ago
Helper II
Thanks!
I tried your measure; however, the output is not as desired.
I need the measure to be dynamic to project the current year growth/decline only. I'm currently achieving the output by applying the year filter to the visual.
I dont want to put any filters. The dax measure should take care of it.