Hello @leungjoot
Welcome back to Quick Sight Community!
Regarding your use-case, I have been looking into a workaround which can help. So for my test dataset, I used Segment column (your case ‘Scenario’ column). When ‘Segment’ Column is ‘Enterprise’, and latest year and latest month is ranked as 1, then it will be 1 else 0.
Firstly, I have extracted year and month as my dataset has date column.
year= extract(‘YYYY’,{Order Date})
month = extract(‘MM’,{Order Date})
Then for ranking, we have to use separate Calculated fields as to get latest year and month through ranking,
rank-test-month =
denseRank(
[max(month) DESC]
)
rank-test-year =
denseRank(
[max(year) DESC]
)
For numeric counterpart of String field, you can use similar to something below:
Segment-numeric
ifelse(Segment=‘Enterprise’,1,2)
You can write like ifelse({Scenario}=‘FORECAST’,1,2)
This numeric conversion was required to avoid mismatched aggregation in Calculated fields. I used min() to match aggregation with rank()
So, now my final Calculated field looks like:
ifelse(
min({Segment-numeric})= 1 AND {rank-test-year} = 1 AND {rank-test-month} = 1,
1, 0)
Hope this helps.
Have a nice day!!