09-09-2022 09:55 AM
Hi ,
We are trying to use the Last_version filter in an aggregated table to get the counts of ID's for the last audit date for that ID. (v5.2.2)
This use case is generating some values but they dont seem to make any sense. We are unable to understand the logic that incorta is using to apply this function.
As there was limited documentation for the feature, it would be helpful if you could provide more insight on the workings of this filter.
Regards,
Rohan
09-11-2022 01:12 AM - edited 09-11-2022 09:05 AM
Sorry misunderstood the question that you were using the lastVersion() function. Please refer to Patrick reply for the correct answer
Hi @rohankamath
You can use the lastVersion() filter function as follows:
firstVersion(<type> value, <type> group_by, date order_by)
Type of value
Returns the last occurrence of a value with respect to date (i.e. the order-by parameter). Unless used as a filter, this function must be used inside an aggregation function.
count(lastVersion(SALES.SALES.AMOUNT_SOLD, SALES.SALES.CUSTOMER_ID, SALES.SALES.AUDIT_DATE))
more in the doc link: https://docs4.incorta.com/4.5/c-filter-functions/#example
Do you want to share sample of your data and screenshot of your analyzer. The result is impacted by the grouping dimensions used in your aggregated table.
09-11-2022 08:53 AM
Sure Rohan....
If I take this example of source data:
OrderId | OrderDate | Amount | ProductId |
1 | 3/1/22 | 3 | 6 |
1 | 3/2/22 | 2 | 6 |
2 | 4/4/22 | 9 | 9 |
3 | 3/1/22 | 6 | 8 |
3 | 4/2/22 | 1 | 7 |
3 | 4/3/22 | 4 | 8 |
Think of that table as a record of orders (there are 3 above) that are placed, and then updated over time. I might apply a Last Version filter (or a First Version filter) to retrieve only the "last version" of the order:
OrderId | OrderDate | Amount | ProductId |
1 | 3/2/22 | 2 | 6 |
2 | 4/4/22 | 9 | 9 |
3 | 4/3/22 | 4 | 8 |
To do that in Incorta, it would look like this:
You drag on the "id" field into Individual Filter panel (think of it as the unique key of the result set or the group by), set the Operator to "Last Version" and then drag the Order Date on to the Values (think of it as the criteria by which we select the row that aligns to that unique key).
Hope that helps, this screenshot comes from an Incorta cloud instance if you wanted to take a look.
Thanks,
Patrick