Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have the data like below for all months.
ID | Month | Value |
A | December | 1 |
B | December | 2 |
C | December | 3 |
D | December | 4 |
A | November | 5 |
B | November | 2 |
C | November | 1 |
I need to flag only present month IDs by comparing with previous month same IDs. I cannot do this in script since my previous month selection is dynamic from drop down list. Suppose if I select November from drop down list, the data should appear like below.
ID | Month | Value | Flag |
A | December | 1 | Decrease |
B | December | 2 | Same |
C | December | 3 | Increase |
D | December | 4 | New |
Flagging is based on comparison of value of same ID of selected month.
{December} C > {November} C -----> Increase
If you dont want to use monthId you could do everything in the set expression as in below. I prefer flags though because it makes everything easier and more clear. But you can use the below expression.
if(Sum(Value)>sum({<Month={"$(=month(addmonths(max(Date),-1)))"}>}Value),'increased','decreased')
If you want to show the selected month in the table as well you could just use an expression.
Expression for showing the month: month(Min(Date))
Good luck and please mark as solution if it works out for you.
If you show the fields ID, Value and Flag and leave out month from your table, you can use this expression
if(Sum(Value)>sum({<Month, MonthId={"$(=max(MonthId)-1)"}>}Value),'increased','decreased')
For it to work you need to create Ids for your month backend. If you have a calendar table, then you just create you id field like:
load *, autonumber(Month) as MonthId
Hope it helped you out.
@AronC , Thank you for your reply.
My current month is max of my date field and I have saved into a variable. In present example, it is December.
My selected month is based on month input from variable input from front end. In present example, it is November.
I shouldn't change my backend script and my current visualization.
Please suggest me. This can be done using set analysis imo. But, I am not getting any ideas here.
If you dont want to use monthId you could do everything in the set expression as in below. I prefer flags though because it makes everything easier and more clear. But you can use the below expression.
if(Sum(Value)>sum({<Month={"$(=month(addmonths(max(Date),-1)))"}>}Value),'increased','decreased')
If you want to show the selected month in the table as well you could just use an expression.
Expression for showing the month: month(Min(Date))
Good luck and please mark as solution if it works out for you.