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

Same period last month

Sum({$<Ano ={$(=Year(today()))},Mês={$(=Month(today()))}, [operacao]={'V'} >}valor)

return the day: 09/04/2016 : VALUE: X

====================================================

As I think for the same day of the previous month

in the above expression

return the day: 09/03/2016 : Value: X

As had been and expression?


Neves
7 Replies
swuehl
MVP
MVP

Hi Agnaldo,

you are using a cyclic month field which is not really good to use when you want to cross year bounderies.

Have a look at Henrics blog

Dates in Set Analysis

In the second half, he exactely describes how you can get the previous month value using a sequential month field.

Hope this helps,

Stefan

P.S. see also

Cyclic or Sequential?

The Magic of Set Analysis - Point In Time Reporting • Blog • AfterSync

Ribeiro
Specialist
Specialist
Author

you would have a hint of the expression:

I take a month before today's date

09/04/2016

for

09/03/2016

Brazil

Neves
swuehl
MVP
MVP

yes, in the referenced blog post there is a detailed example:

Script:

Date(MonthStart(Date),'MMM-YY') as Month,

Expressions:

Sum( {$<Month={"$(=Date(Max(Month),'MMM-YY'))"}>} Amount )

Sum( {$<Month={"$(=Date(AddMonths(Max(Month),-1),'MMM-YY'))"}>} Amount )

Ribeiro
Specialist
Specialist
Author

Did not work

Sum({$<Ano ={$(=Year(today()))},Mês={$(=Month(today()))},Dia={$(=Day(today()))}, [operacao]={'V'} >}valor)

retorna: 09/04/2016

Sum({$<Ano ={$(=Year(today()))},Mês={$(=Month(today()-1))},Dia={$(=Day(today()))}, [operacao]={'V'} >}valor)

retorna: 09/03/2016

Excuse me

He missed the day.

I need something,

But it does not work.

Neves
swuehl
MVP
MVP

First, create an additional field in your script, with a sequential month:

Date(MonthStart(Fecha),'MMM-YY') as AnoMes,

then use this field in your set expressions:

Sum({$<Ano, Mês, Dia, AnoMes ={"$(=Date(Today(),'MMM-YY'))"}, [operacao]={'V'} >}valor)

Sum({$<Ano, Mês, Dia, AnoMes ={"$(=Date(Addmonths(Today(),-1),'MMM-YY'))"}, [operacao]={'V'} >}valor)


Ribeiro
Specialist
Specialist
Author

Sum({$<Ano, Mês, Dia, MesAno ={"$(=Date(Addmonths(Today(),-1),'MMM-YYYY'))"}, [operacao]={'V'} >}valor)

RETURNE : 02016-04-09_20-17-15.png

Neves
swuehl
MVP
MVP

Ah, ignore my previous post, this will not work.

You were asking for the previous month same day:

Do you have a Date (Fecha) field?

Sum({$< Fecha={"$(=Date(Addmonths(Today(),-1),'DD/MM/YYYY'))"}, [operacao]={'V'} >}valor)