here each userid has a plan and start /end date of each plan. User can upgrade/downgrade their plan. here i m looking at the solution where i can identify which is the latest plan for unique userId to consider them for the pricing.
Ex : User1 has A plan . after that he has upgraded to C plan. I want to identify that this is the latest plan to the current month.
While that will work, it relies on an aciton which could lead to concurrency issues. Also, this will create a debug log as the action will not have green checks (clean load). Lastly, for the information to be updated, you will have to run this action, so the perferred way should be using formula's (less concurrency issues).
@rob_marshall's approach is a really good one. See below for another approach you could take:
This is a really great opportunity to use the power of saved views and sorting. What I would do to solve this problem is the following:
In the module where you have your data (let's call it Module 1), sort your dates from "highest to lowest". This will present the dates from latest date to earliest date.
Click View -> Save As... to save the sorted view of the module as a Saved View.
Create a new module (let's call it Module 2) dimensionalized by a UserID List and Line Items, where the line items are Plan, Subscription Start Date, and EndDate. Make sure you format those correctly.
On Module 2, click Data -> Import. Import data from the Saved View of Module 1, making sure to configure the import correctly. Most importantly, make sure to map the UserID text field from Module 1 into the UserID List in Module 2.
When you import from the Saved View, only the first records of each UserID will make it into Module 2. Since your saved view is sorted from latest to earliest, that means that only the latest records of each UserID will be brought into that module.
As always, there's loads more that you can do to make the process more efficient, but this is the basic premise. See attached images for the results!
I think it is needed a basic assumption: the "Valid From", "Valid To" intervals, for the same user, cannot have days in common, otherwise for the common days you can have "valid" in the same time 2 "Plan", which I do not think it is the case.
Based on the above assumption and considering that the current month can be considered as a "Current Date" defined in a general module as parameter you can have this solution:
- Current Date is Apr 12th 2018 in the module DP01
- Import all data in a numbered list in the module OP01
- formula "Current Plan" in OP01:
IF 'DP01. Paremters'.Current Date >= Valid From AND 'DP01. Paremters'.Current Date < Valid To THEN Plan ELSE BLANK
- Formula of "Current Plan" in OP02
'OP01. ALL Data'.Current Plan[FIRSTNONBLANK: 'OP01. ALL Data'.User Id]
Below a print-screen with the results presented in a dashboard: