Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Special YTD formula calculation

Hi everyone

I need to compare last year with current year, but just those months that have sales last year. Additionally I have just Tickets and not canceled ones, and a flag for last year sales.

Example

On one store we just have sales on dic 2014 and on 2015 all year, but I need just to compare dic 2015 vs dic 2014.

My formula look like this

sum({$<

Fecha={">=$(=date(yearstart(max(Fecha))))<=$(=date(max(Fecha)))"},

Mes=P({1<Mes={'=Sum({$< Doc *= {"T*"} - {"TS*"}, TicketCancelado ={0}, Año={$(=year(addmonths(max(Fecha),-12)))" }, Flag ={1} >} Ventas )>0'}>} Mes )

>} Ventas)

Hope somebody could help me!

5 Replies
settu_periasamy
Master III
Master III

Looks like double quotes missing  here -> {$(=year(addmonths(max(Fecha),-12)))" }

May be try this

=sum({$< Fecha={">=$(=date(yearstart(max(Fecha))))<=$(=date(max(Fecha)))"},

              Mes=P({1<Mes={'=Sum({$< Doc *= {"T*"} - {"TS*"}, TicketCancelado ={0},

                                                        Año={"$(=year(addmonths(max(Fecha),-12)))"}, Flag ={1}

                                                >} Ventas )>0'}

                              >} Mes )

      >} Ventas)

jagan
Luminary Alumni
Luminary Alumni

Hi,

Check this link for similar type of expressions

Set Analysis for certain Point in Time

Regards,

Jagan.

Not applicable
Author

Hi Settu

It was a typing error, but that formula does not reflejct the spected result.

Not applicable
Author

Hi Jagan

Actually I don't have troubles with laps of time, is base on sales from an specific store, not periods of time.

jagan
Luminary Alumni
Luminary Alumni

HI,

Attach some sample data and your expected output so that it would be easier to understand and provide the solution.

Regards,

Jagan.