cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
r_fioretti
Frequent Visitor

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
yingyinr
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.

View solution in original post

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 IV
Super User IV

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!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Top Solution Authors
Top Kudoed Authors