cancel
Showing results for
Did you mean:
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

Highlighted
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

#### 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.

#### Power BI Helps Homeless and Trouble Youth

We spoke with Power BI Super User, Greg Deckler, about his charity work

#### Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 355 members 3,045 guests
Recent signins: