Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi All,
I am trying to find the right formula in DAX for this and getting nowhere.
I want to create a measure based on date slicer selection,
the measure should calculate the claim amount for the claims that occurred on a date before the Max selected value of a Date slicer for only the claims in the period after the Max selected value of a Date slicer. In other words, I want my measure to do the following.
OS Amount=
VAR MAX_DATE_SLICER=CALCULATE (
MAX( 'Date'[Date] )
)
Var Ids_After_max_Date=ADDCOLUMNS ( CALCULATETABLE(
SUMMARIZE(CLAIM_TRANSACTION,CLAIM_TRANSACTION[CLAIM_ID]),
FILTER( CLAIM_TRANSACTION,CLAIM_TRANSACTION[TRANS_DATE] >= MAX_DATE_SLICER) ,
FILTER( CLAIM,CLAIM[CLAIM_STATUS]="Treatment Delivered" ) //// This is a related table
),
"CLM_ID", CLAIM_TRANSACTION[CLAIM_ID]
)
Var Final_Amount= CALCULATE(SUM(CLAIM_TRANSACTION[TRANS_AMT_LC]),(CLAIM_TRANSACTION[TRANS_DATE] <= MAX_DATE_SLICER),CLAIM[CLAIM_ID] in VALUES(Ids_After_max_Date[CLM_ID] ))
return Final_Amount
my challenge is how to refer to the column values of a table variable.
I tried to create a calculated table and then refer to its column in my measure using VALUSES('calculated_table'[CLAIM_ID]) but, I ran into another challenge the selected slicer value did not work with the calculated table and the result was blank table.
this is the calculated table measure I created.
calculated_table =
Var MAX_DATE_SLICER= CALCULATE (
MAX( 'Date'[Date] )
)
Var IDs_After_Max_Date= CALCULATETABLE(
SUMMARIZE(CLAIM_TRANSACTION,CLAIM_TRANSACTION[CLAIM_ID]),
FILTER( CLAIM_TRANSACTION,CLAIM_TRANSACTION[TRANS_DATE] >= MAX_DATE_SLICER)
)
return IDs_After_Max_Date
Solved! Go to Solution.
this is a modified version of your code
OS Amount =
VAR MAX_DATE_SLICER =
CALCULATE (
MAX ( 'Date'[Date] )
)
VAR Ids_After_max_Date =
selectcolumns(
ADDCOLUMNS (
CALCULATETABLE (
SUMMARIZE (
CLAIM_TRANSACTION,
CLAIM_TRANSACTION[CLAIM_ID]
),
FILTER (
CLAIM_TRANSACTION,
CLAIM_TRANSACTION[TRANS_DATE] >= MAX_DATE_SLICER
),
FILTER (
CLAIM,
CLAIM[CLAIM_STATUS] = "Treatment Delivered"
) //// This is a related table
),
"CLM_ID", CLAIM_TRANSACTION[CLAIM_ID]
),
"CLM_ID", [CLM_ID]
)
VAR Final_Amount =
CALCULATE (
SUM ( CLAIM_TRANSACTION[TRANS_AMT_LC] ),
CLAIM_TRANSACTION[TRANS_DATE] <= MAX_DATE_SLICER ,
CLAIM[CLAIM_ID]
IN Ids_After_max_Date
)
RETURN
Final_Amount
let me know if it works for you .
If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution ✅!
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠
this is a modified version of your code
OS Amount =
VAR MAX_DATE_SLICER =
CALCULATE (
MAX ( 'Date'[Date] )
)
VAR Ids_After_max_Date =
selectcolumns(
ADDCOLUMNS (
CALCULATETABLE (
SUMMARIZE (
CLAIM_TRANSACTION,
CLAIM_TRANSACTION[CLAIM_ID]
),
FILTER (
CLAIM_TRANSACTION,
CLAIM_TRANSACTION[TRANS_DATE] >= MAX_DATE_SLICER
),
FILTER (
CLAIM,
CLAIM[CLAIM_STATUS] = "Treatment Delivered"
) //// This is a related table
),
"CLM_ID", CLAIM_TRANSACTION[CLAIM_ID]
),
"CLM_ID", [CLM_ID]
)
VAR Final_Amount =
CALCULATE (
SUM ( CLAIM_TRANSACTION[TRANS_AMT_LC] ),
CLAIM_TRANSACTION[TRANS_DATE] <= MAX_DATE_SLICER ,
CLAIM[CLAIM_ID]
IN Ids_After_max_Date
)
RETURN
Final_Amount
let me know if it works for you .
If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution ✅!
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠
@Daniel29195 check this out.
Proud to be a Super User! | |
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
68 | |
53 | |
39 | |
33 |
User | Count |
---|---|
70 | |
63 | |
57 | |
49 | |
46 |