cancel
Showing results for
Did you mean:

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Helper III

## Only show each january from last year

Hi, I want to know how i can see just the information of january's last year, acoording the month_year filter.

i.e: if i filter apr 2019, i want to see data sum(sales) of january 2018.

i.e: if i filter may 2018, i want to see data sum(sales) of january 2017.

1 ACCEPTED SOLUTION
Super User

Hello @kevderbeste

Give this a try.

```Jan PY Sales =
VAR ActiveDate = MAX ( Dates[Date] )
VAR PYNum = YEAR ( ActiveDate ) -1
VAR JanPYDates = FILTER ( ALL ( Dates ) , Dates[Year] = PYNum && Dates[Month Number] = 1)
RETURN
CALCULATE(
[Sales Amount],
JanPYDates
)```
3 REPLIES 3
Super User

Hi,

Assuming you have a Calendar Table with a relationship from the Date column of the Data Table to the Date column of the Calendar Table, create slicer for the Year from the Calendar Table and select any one Year.  Write this measure

=CALCULATE(SUM(Data[Sales]),DATESBETWEEN(Calendar[Date],DATE(MIN(Calendar[Year])-1,1,1),DATE(MIN(Calendar[Year])-1,1,31)))

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com
Super User

Hello @kevderbeste

Give this a try.

```Jan PY Sales =
VAR ActiveDate = MAX ( Dates[Date] )
VAR PYNum = YEAR ( ActiveDate ) -1
VAR JanPYDates = FILTER ( ALL ( Dates ) , Dates[Year] = PYNum && Dates[Month Number] = 1)
RETURN
CALCULATE(
[Sales Amount],
JanPYDates
)```
Helper III

@jdbuchanan71 wrote:

Hello @kevderbeste

Give this a try.

```Jan PY Sales =
VAR ActiveDate = MAX ( Dates[Date] )
VAR PYNum = YEAR ( ActiveDate ) -1
VAR JanPYDates = FILTER ( ALL ( Dates ) , Dates[Year] = PYNum && Dates[Month Number] = 1)
RETURN
CALCULATE(
[Sales Amount],
JanPYDates
)```

Thanks a lot, is the solution.

Announcements

#### Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors