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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Syndicate_Admin
Administrator
Administrator

Dax

Good afternoon community,

I would like to consult you how I could make a measurement in which it allows me to know the value of last year of the current month, also have a parameter of months which when selecting a value "n" decreases me in "n" months of the current month in the previous year.

Example:

next reference image

mavn_0-1659985909258.png

thank you very much in advance

3 REPLIES 3
Duia
Resolver II
Resolver II

Hi  @Syndicate_Admin ,

Here are the steps you can follow:

1. Modeling - New parameter - Create a 0-12 table as a slicer.

Duia_0-1660203409186.png

2. Create measure.

Measure =
var _select=SELECTEDVALUE('periodo'[periodo])
var _today=TODAY()
var _maxdate=MAXX(ALL('Table'),[Date])
return
IF(
    YEAR(MAX('Table'[Date]))=YEAR(TODAY())&&
    MAX('Table'[Date])<=DATE(YEAR(TODAY()),MONTH(_maxdate)-_select,1)
    ,
    CALCULATE(SUM('Table'[valor]),FILTER(ALL('Table'),
    'Table'[Date]=DATE(YEAR(MAX('Table'[Date]))-1,
    MONTH(MAX('Table'[Date]))+_select,1)))
    ,BLANK())

3. Result:

Duia_1-1660203409189.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

tamerj1
Community Champion
Community Champion

Hi Admin @Syndicate_Admin  and @Anonymous 

Why March and April are 0?

Anonymous
Not applicable

coloque datos 0 sin relevancia porque solo mostraba hasta el mes 04/2022 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.