Forum Discussion
RootOfMinusOne
2 years agoFrequent 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!
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] )
1 Reply
- DataInsights
Super User
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] )