Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have created a variable to store the prior month that user selects.
vPriorMonth = Date(addmonths(MonthStart(SnapDate),-1),'MMM-YY')
Purpose is to show the previous month's balance if a month is selected.
eg. User select SnapDate = Jul-16
The following expression will generate these outputs
$(vPriorMonth) => Jun-16
Sum({$<SnapDate=, SnapDate={'Jun-16'}>}MonthEndBalance) => The correct balance if I hardcoded it
Sum({<SnapDate=, SnapDate={'$(vPriorMonth)'}>}MonthEndBalance) => No results
Sum({<SnapDate=, SnapDate={$(=vPriorMonth)}>}MonthEndBalance) => => No results
I have narrowed it down to the issue is that it is a date field as I have replaced the date check with a unrelated check and the code works fine.
Is there any way to get the set analysis to work?
Additional info, not too sure if it helps.
The date format in the load editor:
SET DateFormat='DDMMMYYYY';
How SnapDate is loaded:
Date(MonthStart(SNAP_DATE),'MMM-YY') AS SnapDate
Are you using SnapDate as a dimension and you are hoping to get the prior month by row?
If so, you cannot use a set expression - the set expression is evaluated for the table as a whole, and not on a row by row basis. For this case, use a Sum(If(..)) expression or create a derived prior month field in your load script.
If not, use an aggregate function like Max(..) in your variable definition to ensure that it can be evaluated at a global level.
Als, you cannot refer to the same field twice in the set expression. If you do, the first refreence will be ignored. So the first reference to SnapDate in Sum({<SnapDate=, SnapDate={'$(vPriorMonth... will be ignored and clutters your expression for no purpose.