cancel
Showing results for
Did you mean:
Highlighted
Frequent Visitor

## YTD and YTD prior

Hello,

I am trying to pull in an average YTD and YTD prior year up to Jan 6th in a bar graph. I am able to pull in the YTD using the =TOTALYTD (AVERAGE(.....)) formula, but can anyone please help to figure out how to pull the average YTD prior year for the same period in Desktop Power BI? I am trying to pull both the YTD and YTD prior year in a same bar graph.

 01/06/17 1 01/05/17 1 01/04/17 2 01/03/17 3 01/02/17 3 01/01/17 1 01/31/16 1 01/30/16 5 01/29/16 4 01/28/16 2 01/27/16 4 01/26/16 7 01/25/16 6 01/24/16 5 01/23/16 6 01/22/16 9 01/21/16 8 01/20/16 7 01/19/16 6 01/18/16 4 01/17/16 1 01/16/16 2 01/15/16 5 01/14/16 4 01/13/16 2 01/12/16 3 01/11/16 1 01/10/16 5 01/09/16 4 01/08/16 3 01/07/16 1 01/06/16 1 01/05/16 1 01/04/16 1 01/03/16 2 01/02/16 3 01/01/16 1
1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft

## Re: YTD and YTD prior

Hi @jagdishpatil,

I try to reproduce your scenario and get expected result.

First, create measure to calculate YTD and prvious YTD value.

```average = TOTALYTD(AVERAGE(Table2[Value]),Table2[Date])

Prior = CALCULATE(Table2[average],SAMEPERIODLASTYEAR(Table2[Date]))```

Then create a stacked column chart and add the two measures above as value levels, please see the following screenshot.

Best Regards,
Angelia

6 REPLIES 6
Microsoft

New Contributor

## Re: YTD and YTD prior

Try

CALCULATE( TOTALYTD( AVERAGE...), SAMEPERIODLASTYEAR( [DateCol] ) )

Hope this helps

David

Senior Member

## Re: YTD and YTD prior

or:

`TOTALYTD( AVERAGE( Table[Column] ), SAMEPERIODLASTYEAR ( Calendar[Date] ) )`
Microsoft

## Re: YTD and YTD prior

Hi @jagdishpatil,

I try to reproduce your scenario and get expected result.

First, create measure to calculate YTD and prvious YTD value.

```average = TOTALYTD(AVERAGE(Table2[Value]),Table2[Date])

Prior = CALCULATE(Table2[average],SAMEPERIODLASTYEAR(Table2[Date]))```

Then create a stacked column chart and add the two measures above as value levels, please see the following screenshot.

Best Regards,
Angelia

Frequent Visitor

## Re: YTD and YTD prior

In the solutions offered above the DAX formula "SAMEPERIODLASTYEAR" is used to generated Prior Year YTD. However, for my case i cannot use SAMEPERIODLASTYEAR because it doesn't allow for "true/false" comparisons as the conditions is a column. wondering if anyone has an idea on how to circunvent this issue.

New Contributor

## Re: YTD and YTD prior

Hi @lerodriguez  - as this thread is almost 3 years old it is better to start a new thread than reply to this one. That way you can give all of the details you need and we can focus on solving your particular issue.

Announcements