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
L_K_
Helper I
Helper I

How to sum last year’s values that are relevant this year

Hello,

 

I have a table for my suppliers and their values over the years (It is a simplified example).

Company 

Value 

Year 

10 

2022 

12 

2022 

11 

2021 

14 

2021 

13 

2022 

B

10

2022 

2022 

2021 

12 

2021 

2021 

2021 

2021 

 

Now if we use a matrix to show the sum of values per company and year, we get the next table:

Company 

2021 

2022 

25 

22 

26 

32 

12 

 

Total 

63 

54

 

Now I put the year in a slicer to jump between 2022 and 2021 and made a measure to show me last year’s values for the comparison of values for each company.

 

Value_last_year = IF(NOT(ISBLANK(TABLE[VALUE])),CALCULATE((TABLE[VALUE]),'DATE'[YEAR]= SELECTEDVALUE('DATE'[YEAR])-1),BLANK())

 

Which gives me the next result:

Company 

Last year 

This year 

25 

22 

26 

32 

Total 

63 

54 

 

My problem is that I only want to summarize last year’s values in the measure for the companies that have a value this year. Like Company C doesn’t have values this year, but it still counts that value in the total row.

 

So, I would like my sum total to look like this:

Company 

Last year 

This year 

25 

22 

26 

32 

Total 

51 

54 

 

How can I make a measure that summarizes last years values, but only for the companies that have a value this year?

 

I also have a lot of data, so I don’t want to make a separate table for the measures.

 

Thank you.

1 ACCEPTED SOLUTION

6 REPLIES 6
tamerj1
Super User
Super User

Hi @L_K_ 

please try

 

 

 

 

Value_last_year =
CALCULATE (
    SUM ( TABLE[VALUE] ),
    KEEPFILTERS ( 'DATE'[YEAR] = SELECTEDVALUE ( 'DATE'[YEAR] ) - 1 )
)

 

 

 

 

Hi,

no, this doesn't work since it's kind of the same as I already have. 

Your calculation does not exclude last years values from companies that don’t have a value this year. Which is the answer I am looking for.

Hi @L_K_ 
Esiest to use the filter pane

1.png2.png

1.png

Filtering doesn't work for my actual set of data.

Thank you though.

@L_K_ 

Here is the solution as wish https://www.dropbox.com/t/Xckbmy4zeHiGVQBv

1.png

Thank you so much @tamerj1

I really appreciate it! This works better.

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.