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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply

How to pass month-year values to filter

I have a slicer in a pbi page for date, I need to calculate the sales for the previous year of the selected period in the slicer not the sameperiodlastyear, for example if I select in the slicer from 01/01/2023 to 31/01/2023 it should calculate for all the year of 2022.

I have a dimension table for Dates and a fact table for Sales connected through SALES[Date] and DATES[Date]. The Dates table have the columns Year, Date and Month-Year.

The visual that I am using is a chart bar where the X-axis is month-year. How can I do the calculation only for the values of month-year of the previous year considering what I said at the beggining?

Maybe something like the following but I don't know how to filter DATES by DATES[YEAR] and only get the values of the previous year of DATES[monthYear] to pass to CALCULATE.

Total Net Value =
VAR previousYear = MAX(DATES[Year])

VAR monthYearValuesPreviousYear = VALUES(......)????

RETURN
CALCULATE(
    SUM(SALES[netValue]),
    DATES[monthYear] IN monthYearValuesPreviousYear 
)

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

you should use the second date table for the slice

Screenshot_2.pngScreenshot_3.pngScreenshot_1.png

View solution in original post

3 REPLIES 3
Ahmedx
Super User
Super User

you should use the second date table for the slice

Screenshot_2.pngScreenshot_3.pngScreenshot_1.png

Ahmedx
Super User
Super User

pls try this

you need to create a separate date table
and use it to slice

 

Thank you for your reply, but my X-axis is month-year. I adapted the sample to show what I am trying to achieve

ModelModelDesignDesignMeasureMeasure

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.