Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
rnguyen2
Contributor
Contributor

Qlik Sense Set Analysis Expression Previous Period Sum

Hello,

I need some help with my set analysis expression.

I am trying to populate the beginning AR Balance for the month with the ending AR Balance for the prior month.

Below is my set expression.

Sum({$<[posting_date.autoCalendar.Date]={"$=addmonths([posting_date.autoCalendar.Date],-1)"}, BALANCE_TYPE={"DEBIT_BALANCE"}>} [AR BALANCE])

2019-02-26_13-03-13.png

16 Replies
rogerpegler
Creator II
Creator II

Assuming everything else is OK, you may be missing brackets:

Sum({$<[posting_date.autoCalendar.Date]={"$(=addmonths([posting_date.autoCalendar.Date],-1))"}, BALANCE_TYPE={"DEBIT_BALANCE"}>} [AR BALANCE])

rnguyen2
Contributor
Contributor
Author

This did not work either
rnguyen2
Contributor
Contributor
Author

Here a mock up I put together and attached

rogerpegler
Creator II
Creator II

Having seen the app - @sunny_talwar 's solution of using the Before function should work.  Note it only works in Pivot tables.

 

sunny_talwar
MVP
MVP

I used this

Alt(Before(Sum({<BALANCE_TYPE={"DEBIT_BALANCE"}>} [AR BALANCE])), 0)

to get this

Capture.PNG

Is this not right?

rnguyen2
Contributor
Contributor
Author

I could use that function but it shows the incorrect value if I filter certain YearMonths.

In the example attached. I need it to keep 2019-Feb Ending Gross AR Balance for 2019-Mar Beginning Gross AR Balance.

sunny_talwar
MVP
MVP

For that you can try this

Alt(Before(Sum({<BALANCE_TYPE = {"DEBIT_BALANCE"}, [posting_date.autoCalendar.YearMonth]>} [AR BALANCE])), 0) * Avg(1)