Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Trend indicator in matrix ccomparing years

Hello everyone, I would like to create a matrix visual that looks like the following table:     I struggle to create the trend indicator. The arrows should indicate whether the number of ...
  • Jihwan_Kim's avatar
    5 years ago

     

    Trend indicator : =
    VAR _startyear =
    CALCULATE ( MIN ( 'Calendar'[Year] ), REMOVEFILTERS ( 'Calendar' ) )
    VAR _latestyear =
    CALCULATE ( MAX ( 'Calendar'[Year] ), REMOVEFILTERS ( 'Calendar' ) )
    VAR _currentyear =
    MAX ( 'Calendar'[Year] )
    VAR _previousyear = _currentyear - 1
    VAR _currentyearqty = [Sold Items Total :]
    VAR _previousyearqty =
    CALCULATE ( [Sold Items Total :], 'Calendar'[Year] = _previousyear )
    VAR _comparetoPreviousYear =
    IF (
    NOT ISBLANK ( _previousyearqty ),
    IF ( _currentyearqty >= _previousyearqty, "🔼", "🔽" )
    )
    VAR _startyearqty =
    CALCULATE ( [Sold Items Total :], 'Calendar'[Year] = _startyear )
    VAR _latestyearqty =
    CALCULATE ( [Sold Items Total :], 'Calendar'[Year] = _latestyear )
    VAR _overalltrend =
    IF ( _latestyearqty >= _startyearqty, "🔼", "🔽" )
    RETURN
    IF (
    HASONEVALUE ( Items[Item] ),
    SWITCH (
    TRUE (),
    ISINSCOPE ( 'Calendar'[Year] ), _comparetoPreviousYear,
    _overalltrend
    )
    )

     

     

    Link to the sample pbix file