Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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