Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Razan_Omoush
Frequent Visitor

How to refer to columns values of a table variable

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    

1 ACCEPTED SOLUTION
Daniel29195
Super User
Super User

@Razan_Omoush 

 

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! 🤠

View solution in original post

2 REPLIES 2
Daniel29195
Super User
Super User

@Razan_Omoush 

 

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! 🤠

Idrissshatila
Super User
Super User

@Daniel29195  check this out.



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.