Skip to main content
cancel
Showing results for 
Search instead 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.

Reply
kevderbeste
Helper III
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
jdbuchanan71
Super User
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
    )

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
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
https://www.linkedin.com/in/excelenthusiasts/
jdbuchanan71
Super User
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
    )

hi @jdbuchanan71 


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

Helpful resources

Announcements
Microsoft Fabric Learn Together

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

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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