cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
r_fioretti
New Member

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

Accepted Solutions
r_fioretti
New Member

Re: SAMEPERIODLASTYEAR WITH FILTER

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

Re: SAMEPERIODLASTYEAR WITH FILTER

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


---------------------------------------

Putting square pegs in round holes since 1972.

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

Microsoft
Microsoft

Re: SAMEPERIODLASTYEAR WITH FILTER

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

r_fioretti
New Member

Re: SAMEPERIODLASTYEAR WITH FILTER

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

Microsoft
Microsoft

Re: SAMEPERIODLASTYEAR WITH FILTER

Hi @r_fioretti,

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

Best Regards

Rena

r_fioretti
New Member

Re: SAMEPERIODLASTYEAR WITH FILTER

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

Microsoft
Microsoft

Re: SAMEPERIODLASTYEAR WITH FILTER

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

Helpful resources

Announcements
‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

Announcing the New Spanish Forum

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

April 2020 Community Highlights

April 2020 Community Highlights

Info on our Super Users, MBAS content and badges, and updates to our support articles. - Read the full Community Highlights.

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

Top Solution Authors
Top Kudoed Authors