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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
zervino
Helper I
Helper I

Table with year and deltas

I have raw data with this format:

 

TeamYearSales
A20216345
B20214554
C20218525
A20227000
B20224634

C

20227122

A

20238788

B

20233437

C

20235998

 

I have data for many different teams and many different years.

 

The output should be a table like this:

 

Team20232022Delta
A878870001788
B34374634-1197
C59987122-1124

 

I have a drop down in the dashboard where I can select the two years to compare, but the output will still show the results for all teams.

 

What's the best way to achieve this kind of table?

2 ACCEPTED SOLUTIONS
Ritaf1983
Super User
Super User

Hi @zervino 

You can apply these steps :
1. Create the table for Years :

Years = DISTINCT('Table'[Year])
Ritaf1983_0-1715362404041.png

2. create a relationship with your table:

Ritaf1983_1-1715362465714.png

3. Create 3 measures :

Max Year = CALCULATE(sum('Table'[Sales]) ,'Years'[Year]=max('Years'[Year]) )
Min Year = CALCULATE(sum('Table'[Sales]) ,'Years'[Year]=min('Years'[Year]) )
Delta = [Max Year]-[Min Year]
4. create a visual:
Ritaf1983_2-1715362947225.png

pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

Hi @zervino 

 

You can create a measure like below. Use a matrix visual instead of a table visual. Add Team to rows, Add Year to column and add the measure to Values. Rename the column total from the default "Total" to "Delta". 

Value = IF(ISINSCOPE(Years[Year]),SUM('Table'[Sales]),[Delta])

vjingzhanmsft_0-1715569173531.pngvjingzhanmsft_2-1715569229173.png

 

vjingzhanmsft_1-1715569192418.png

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

 

View solution in original post

5 REPLIES 5
Ritaf1983
Super User
Super User

Hi @zervino 

You can apply these steps :
1. Create the table for Years :

Years = DISTINCT('Table'[Year])
Ritaf1983_0-1715362404041.png

2. create a relationship with your table:

Ritaf1983_1-1715362465714.png

3. Create 3 measures :

Max Year = CALCULATE(sum('Table'[Sales]) ,'Years'[Year]=max('Years'[Year]) )
Min Year = CALCULATE(sum('Table'[Sales]) ,'Years'[Year]=min('Years'[Year]) )
Delta = [Max Year]-[Min Year]
4. create a visual:
Ritaf1983_2-1715362947225.png

pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

The problem with this approach is that the column title is not dynamic, it would be "max year", but depending on which years the user chooses, I would like to see eg. 2022 and 2016

Hi @zervino 

 

You can create a measure like below. Use a matrix visual instead of a table visual. Add Team to rows, Add Year to column and add the measure to Values. Rename the column total from the default "Total" to "Delta". 

Value = IF(ISINSCOPE(Years[Year]),SUM('Table'[Sales]),[Delta])

vjingzhanmsft_0-1715569173531.pngvjingzhanmsft_2-1715569229173.png

 

vjingzhanmsft_1-1715569192418.png

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

 

@zervino 

For dynamic measure names you can use a workaround with field parameters .
Please refer to the linked video:

https://www.youtube.com/watch?v=9_2m5Csr55c

 

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

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
ajohnso2
Solution Supplier
Solution Supplier

1. Add a dimension table of your years

2. Add a dimension table of your teams

3. Join years & team table to your 'Fact'

4. Use dax to calculate a new measure for LY

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!

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.