Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Need help removing IF statement in front of Set Analysis

Can someone please help me figure out how to get rid of this IF statement in the beginning of my SET analysis?

This script works fine and returns the correct values:

=if(MonthYear= date($(=max(MonthYear)),'MMM-YYYY'),
    sum({$<
        CheckYear = {$(=Max(CheckYear))},
        PrimaryPositionYN={1},
        EarningsHistoryYN -= {1},
        NonCashYN = {0}
        >}
    [Current Earnings])
)

Any help would be appreciated.

1 Solution

Accepted Solutions

Re: Need help removing IF statement in front of Set Analysis

Hi,

It depends what kind dimension you are using, If you are using MonthYear as Dimension also then you have to use that if statement .

If you are not using as dimension then

try

sum({$<

        MonthYear={"$(=date(max(MonthYear),'MMM-YYYY'))"}
        CheckYear = {$(=Max(CheckYear))},
        PrimaryPositionYN={1},
        EarningsHistoryYN -= {1},
         NonCashYN = {0}
>}
[Current Earnings])

Regards

Regards,
Prashant Sangle
2 Replies
anbu1984
Honored Contributor III

Re: Need help removing IF statement in front of Set Analysis

Do you want calculate Sum for all MonthYear? Then try this

sum({$<

        CheckYear = {$(=Max(CheckYear))},

        PrimaryPositionYN={1},

        EarningsHistoryYN -= {1},

        NonCashYN = {0}

        >}

    [Current Earnings])

Re: Need help removing IF statement in front of Set Analysis

Hi,

It depends what kind dimension you are using, If you are using MonthYear as Dimension also then you have to use that if statement .

If you are not using as dimension then

try

sum({$<

        MonthYear={"$(=date(max(MonthYear),'MMM-YYYY'))"}
        CheckYear = {$(=Max(CheckYear))},
        PrimaryPositionYN={1},
        EarningsHistoryYN -= {1},
         NonCashYN = {0}
>}
[Current Earnings])

Regards

Regards,
Prashant Sangle
Community Browser