cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
azaterol
Helper V
Helper V

Date last years

Hey everybody,

 

how can I show dynamically the same month that I choose in 2022 for the last years. 

If I choose from 1. March- 31. March 2022, I want that the fields show unter the sale years, the sales for 1. March 2020 - 31. March 2020 and 1. March 2021 - 31. March2021. 

 

You have an idea for a dax?

Thank you all. 

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @azaterol ,

 

Please try these measures.

 

Current year sales = 
CALCULATE (
    SUM ( 'Sales'[Sales] ),
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Year]
            = MAX ( 'Calendar'[Year] ) 
            && 'Calendar'[Month] = MAX ( 'Calendar'[Month] )
    )
)
Last year sales = 
CALCULATE (
    SUM ( 'Sales'[Sales] ),
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Year]
            = MAX ( 'Calendar'[Year] ) - 1
            && 'Calendar'[Month] = MAX ( 'Calendar'[Month] )
    )
)
Previous year sales = 
CALCULATE (
    SUM ( 'Sales'[Sales] ),
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Year]
            = MAX ( 'Calendar'[Year] ) - 2
            && 'Calendar'[Month] = MAX ( 'Calendar'[Month] )
    )
)

 

vcgaomsft_0-1657073342393.png

Please feel free to let me know if I misunderstood your needs.

The PBIX file is attached for reference.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @azaterol ,

 

Please try these measures.

 

Current year sales = 
CALCULATE (
    SUM ( 'Sales'[Sales] ),
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Year]
            = MAX ( 'Calendar'[Year] ) 
            && 'Calendar'[Month] = MAX ( 'Calendar'[Month] )
    )
)
Last year sales = 
CALCULATE (
    SUM ( 'Sales'[Sales] ),
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Year]
            = MAX ( 'Calendar'[Year] ) - 1
            && 'Calendar'[Month] = MAX ( 'Calendar'[Month] )
    )
)
Previous year sales = 
CALCULATE (
    SUM ( 'Sales'[Sales] ),
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Year]
            = MAX ( 'Calendar'[Year] ) - 2
            && 'Calendar'[Month] = MAX ( 'Calendar'[Month] )
    )
)

 

vcgaomsft_0-1657073342393.png

Please feel free to let me know if I misunderstood your needs.

The PBIX file is attached for reference.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

calerof
Impactful Individual
Impactful Individual

Hi @azaterol ,

Do you have a Date table?  If not, you can create one following Reza's blog.

Then you just select the month and the filter shows you all the data for that month, as follows:

data1.pngdata2.png

Hope it helps.

Regards,

Fernando

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors