# QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Not applicable

## year-to-date and periodic via Indicator in Script

Hi,

I hope someone of you can help me.

We have reports where we define in the calculations year-to-date(YTD) amounts:

Example for YTD

=
((
sum({\$ <Jahr = {\$(=Only(Jahr))}, Monat = {"<=\$(=max({<Jahr={\$(=max(Jahr))}>} Monat))"}, balcode={\$(BALCODE1)}, key_yr={\$(=Only(Jahr))}, key_month={\$(=Only(Monat))} >}[Saldenbetrag]*key_Proz)

Example for Periodic

sum({\$ <Jahr={\$(=Only(Jahr)-1)}, Monat={'*'}, El1_GRPCODE={'1KTO-BIL','1KTO-GUV'}, balcode={\$(BALCODE1)} >}[Saldenbetrag])

The Issue is, that we sometimes need the YTD-View and sometimes only periodical view (in several reports).

Does someone of you maybe have an idea how to create a variable directly in the Script that defines periodic or YTD-View

So that I can easily Switch or Show both in one table?

Chris

3 Replies
Highlighted
Contributor III

## Re: year-to-date and periodic via Indicator in Script

Hi Christian,

I think you can do it in chart properties by enabling conditionally and setting a variable for that

Not applicable

## Re: year-to-date and periodic via Indicator in Script

Hi aswin,

I thought of that too. But when I make a condition I have all calculations twice (one for YTD and one for periodic),

I wanted to get rid of the many calculations by using a defined string within the calculation for YTD and periodical View.

The optimal solution is a button that Switches between These two 🙂

How can I put a variable for that string (Monat = {"<=\$(=max({<Jahr={\$(=max(Jahr))}>} Monat))"},) directly in the script?

("Monat" is month, "Jahr" is Year)

Chris

Contributor III

Hi Christian,