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
r_fioretti
Helper I
Helper I

SAMEPERIODLASTYEAR WITH FILTER

Hello everyone, I’m new in the community and I have the following issue:

 

I’ve created a measure to calculate the increase/decrease over the same period of the previous year. When I use the month in category it’s accumulating the increase/decrease no matter the year of the data.

I’d like to use a filter into the DAX to get the same result I get when I’m using the filter panel or selecting the data on other chart.

 

The measure I’m using is:

Variação Vendas sobre Ano anterior = sum(Base_de_Dados[Valor Faturado])-

CALCULATE(sum(Base_de_Dados[Valor Faturado]);SAMEPERIODLASTYEAR(Calendario[Data]))

 

I’ve tried to use an YEAR(MAX(table[date])) and/OR FILTER() into the CALCULATE  function but isn’t working.

Any ideas?


Tks

PrtScr1.png

 

 PrtScr2.pngPrtScr3.png

 

1 ACCEPTED SOLUTION

Hello,
I've been able to get the result filtering the visual by TOP N 1 Max Year.

Thank you for your support.

PrtScr4.png

 

Regards.

View solution in original post

6 REPLIES 6
v-yiruan-msft
Community Support
Community Support

Hi @r_fioretti ,

Please try to create a measure as below:

Variação Vendas sobre Ano anterior =
SUM ( 'Base_de_Dados'[Valor Faturado] )
    - CALCULATE (
        SUM ( 'Base_de_Dados'[Valor Faturado] ),
        DATEADD ( 'Base_de_Dados'[Date], -1, YEAR )
    )

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello,
Thank you for your answer, however it didn’t work. When I apply a filter on other report I get an error. 😞

Hi @r_fioretti,

Could you please provide the screenshot with that error info if it is convenient? Thank you.

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello,
I've been able to get the result filtering the visual by TOP N 1 Max Year.

Thank you for your support.

PrtScr4.png

 

Regards.

Hi @r_fioretti,

Is there anything else that can help you for this thread? If no, could you please mark it as Answered? Thank you.

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.