Forum Discussion
Date Analysis
To achieve your objective of comparing Platinum with Silver Plan Dates and identifying the Silver plan with the minimum closest date for each GroupMemberID, you can use DAX (Data Analysis Expressions) in Power BI or other similar tools. You'll need to create a calculated column or measure that performs the necessary calculations. Below is the suggested approach:
Assuming you have a table named "CoveragePlans" with columns: GroupId, GroupMemberId, Employee, Coverage Plan, and Date, and you want to create a new column named "Expected Results Column":
You can use the following DAX expression for the "Expected Results Column":
Expected Results Column =
VAR CurrentGroupMemberId = CoveragePlans[GroupMemberId]
VAR CurrentDate = CoveragePlans[Date]
VAR CurrentCoveragePlan = CoveragePlans[Employee Coverage Plan]
RETURN
IF (
CurrentCoveragePlan = "Platinum",
VAR MinSilverDate =
CALCULATE (
MIN ( CoveragePlans[Date] ),
FILTER (
CoveragePlans,
CoveragePlans[GroupMemberId] = CurrentGroupMemberId &&
CoveragePlans[Employee Coverage Plan] = "Silver" &&
CoveragePlans[Date] >= CurrentDate &&
NOT ( CoveragePlans[Date] IN { CurrentDate } )
)
)
RETURN
IF (
ISBLANK ( MinSilverDate ),
BLANK (),
"X"
),
BLANK ()
)
This expression first filters the rows where the coverage plan is "Platinum". For each Platinum plan row, it looks for the minimum date in the "Silver" plans that belong to the same GroupMemberId, are on or after the current Platinum date, and have not been used before. If a minimum Silver date is found, it returns "X"; otherwise, it returns BLANK().
You can add this DAX expression to a calculated column in your Power BI data model, or you can adapt it to use as a measure depending on your reporting requirements.
Please adjust the table and column names accordingly based on your actual data model. This DAX expression assumes that the data structure is similar to what you've provided.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.