cancel
Showing results for
Did you mean:
Highlighted
Frequent Visitor

## calculate last year sales from multiple years pass from slicer

Hi,

I would like to know how we can calculate last year sale when multiple years value pass from slicer.

Example: -

Slicer have values like 2011,2012,2013,2014 if we select all the years then how we can calculate the sale.

I used the above code it is working fine when there is only 1 value select in the slicer.

lastYearsalesAmount = calculate(SUM(Yearbysale[Sales]),Yearbysale[Year] in { VALUES(Yearbysale[Year])-1}, ALLEXCEPT(Yearbysale,Yearbysale[Year]))

1 ACCEPTED SOLUTION

Accepted Solutions
Super Contributor

## Re: calculate last year sales from multiple years pass from slicer

Hi @Mona01 ,

```lastYearsalesAmount =
CALCULATE (
SUM ( Yearbysale[Sales] ),
FILTER (
ALLSELECTED ( Yearbysale ),
Yearbysale[Year]
= MAX ( Yearbysale[Year] ) - 1
)
)```

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 REPLIES 3
Super User

## Re: calculate last year sales from multiple years pass from slicer

Hi @Mona01,

Please see the below to calculate Last Years Sales

```LY Sales =
CALCULATE(
[Sales],
SAMEPERIODLASTYEAR('Calendar'[Date])
)```

Hope this Helps
Mariusz

Frequent Visitor

## Re:Re: calculate last year sales from multiple years pass from slicer

Hi Mariusz,

I have  only a year column ,your solution is working on date . Could u suggest other option for year Column for multiple selection in slicer .

I have a table like that.

 Year Sales 2011 100 2011 100 2011 100 2012 50 2012 50 2012 50 2013 30 2013 30 2013 30 2014 20 2014 20 2014 20

In the slicer for year i select thr years (2011,2012,2013)

Super Contributor

## Re: calculate last year sales from multiple years pass from slicer

Hi @Mona01 ,

```lastYearsalesAmount =
CALCULATE (
SUM ( Yearbysale[Sales] ),
FILTER (
ALLSELECTED ( Yearbysale ),
Yearbysale[Year]
= MAX ( Yearbysale[Year] ) - 1
)
)```

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Announcements

#### Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

#### Community News & Announcements

Get your latest community news and announcements.

#### Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 186 members 2,028 guests
Recent signins: