Last Non-Zero Occurrence

Vicky_Kapri
New Contributor

Last Non-Zero Occurrence

There is a requirement where in module 1(Pic 1), there are some transactions and users wants the Last Non-Zero occurrence in Module 2. How we can get the Last Non-Zero data in module 2(Pic 2)? Highlighted are the numbers that we want in module 2.

 

Module 1

Vicky_Kapri_2-1610904100437.png

 

Module 2

Vicky_Kapri_0-1610904056043.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
nathan_rudman
Master Anaplanner/Community Boss

Re: Last Non-Zero Occurrence

As mentionned, you'll need to use the summary type "Closing Balance".

But first you'll have to create a technical line item that will take the latest non 0 value forward with the following formula:

IF value <> 0 then value else previous(technical line item)

This LI you change its summary type to closing balance. And then you can reference its value with a LOOKUP for a specific year (or [SELECT:Time.all periods] in your module two)


Nathan Rudman, Anaplan Model Builder

View solution in original post

5 REPLIES 5
kevin.cho
Certified Master Anaplanner

Re: Last Non-Zero Occurrence

Hi,

A simple way to do this would be probably to turn on Time Summaries onto the line item, setting it as "Closing Balance". You'll need to have the "All Periods" time setting on your model/timescale for this to work however. 

 

After you have these, you can then reference the line item with a [SELECT: Time.All Periods]. This will give you the closing balance of that line item overall, which will be the last entered value. 

nathan_rudman
Master Anaplanner/Community Boss

Re: Last Non-Zero Occurrence

As mentionned, you'll need to use the summary type "Closing Balance".

But first you'll have to create a technical line item that will take the latest non 0 value forward with the following formula:

IF value <> 0 then value else previous(technical line item)

This LI you change its summary type to closing balance. And then you can reference its value with a LOOKUP for a specific year (or [SELECT:Time.all periods] in your module two)


Nathan Rudman, Anaplan Model Builder

View solution in original post

kevin.cho
Certified Master Anaplanner

Re: Last Non-Zero Occurrence

 

"But first you'll have to create a technical line item that will take the latest non 0 value forward with the following formula:"

 

Yes definitely! Thanks @nathan_rudman , did forget about that step. 

Kanishq17
Community Boss

Re: Last Non-Zero Occurrence

Hi ,

 

You can create a new line item and use formula , if value<>0 then value else previous(value) and then in module refer that line item[select time.'dec 20'] to get value of last month of timescale which will be last non zero value, alternatively , you can use all periods and select time summary as time:closing balance

 

 

ChrisHeathcote
Community Boss

Re: Last Non-Zero Occurrence

@Vicky_Kapri 

As an alternative could you use TIMESUM and the LASTNONBLANK aggregation method?

The start and end position is driven from the CURRENT PERIOD in the time settings so this will need to be taken into account. Also, TIMESUM should only be used when the target module (module2) does not contain time as a dimension.

 

Chris Heathcote
Bedford Consulting

Gold Partner and Regional Partner of the Year 2021, EMEA