Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Trend indicator in matrix ccomparing years

Hello everyone,


I would like to create a matrix visual that looks like the following table:

 

Starter_0-1628504396844.png

 

I struggle to create the trend indicator. The arrows should indicate whether the number of sold items in one year increased or decreased compared to the last year. Also, there should be an overall arrow indicating whether the number of sold items increased or decreased per item over all years.

 

Thank you so much in advance!

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Picture1.png

 

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 

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1628663598903.png

Here are the steps you can follow:

1. Create calculated column.

Column =
var _2019=SUMX(FILTER(ALL('Table'),'Table'[Item]=EARLIER('Table'[Item])&&'Table'[Year]=2019),[No.of sold items])
var _all=SUMX(FILTER(ALL('Table'),'Table'[Item]=EARLIER('Table'[Item])&&'Table'[Year]=EARLIER('Table'[Year])),'Table'[No.of sold items])
return
SWITCH(
    TRUE(),
    _all>_2019,UNICHAR ( 9650 ),
    _all=_2019,BLANK(),
    _all<_2019,UNICHAR ( 128315 ))

2. There seems to be no green arrow in unichar, so we choose green for Format-Field formatting-Font color.

vyangliumsft_1-1628663598905.png

3. Result:

vyangliumsft_2-1628663598908.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Jihwan_Kim
Super User
Super User

Picture1.png

 

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 

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.