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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
RootOfMinusOne
Frequent Visitor

DAX: datatable as temporary table inside a measure- how to do it

Hi

 

I would very much like to have a static temporary table in my measure , where I could do something like this

 

myFooBarMeasure =
var theTempTable = DataTable("country", STRING,"factor", DOUBLE ,{{"SE",0.15},{"NO",0.15},{"DK",30.0},{"FI",0.18}}  )  
 return calculate(MAX('theTempTable'[factor]),FILTER('theTempTable','theTempTable'[country] = SELECTEDVALUE(Position[Country])))
 
but this this results in an error "cannot find 'theTempTable'".
 
Is there a way to do this?
(of course there are workarounds but this would allow me to declare the values in the top of the very complex measure, making it easy for onyone to find and change them)
 
 
thanks!
1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@RootOfMinusOne,

 

Try this measure:

 

myFooBarMeasure = 
VAR theTempTable =
    DATATABLE (
        "country", STRING,
        "factor", DOUBLE,
        {
            { "SE", 0.15 },
            { "NO", 0.15 },
            { "DK", 30.0 },
            { "FI", 0.18 }
        }
    )
VAR theTempTableRow =
    FILTER ( theTempTable, [country] = SELECTEDVALUE ( Position[Country] ) )
RETURN
    MAXX ( theTempTableRow, [factor] )

DataInsights_0-1704386274661.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
DataInsights
Super User
Super User

@RootOfMinusOne,

 

Try this measure:

 

myFooBarMeasure = 
VAR theTempTable =
    DATATABLE (
        "country", STRING,
        "factor", DOUBLE,
        {
            { "SE", 0.15 },
            { "NO", 0.15 },
            { "DK", 30.0 },
            { "FI", 0.18 }
        }
    )
VAR theTempTableRow =
    FILTER ( theTempTable, [country] = SELECTEDVALUE ( Position[Country] ) )
RETURN
    MAXX ( theTempTableRow, [factor] )

DataInsights_0-1704386274661.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors