Forum Discussion
rks
2 years agoResolver II
Return a Table Statement from IF-condition (for TREATAS)
Hi folks, I receive an error message: The TREATAS function expects a table expression for argument '1', but a string or numeric expression was used. I have the following measure: ...
- 1 year ago
Hi,
I was having the same issue as you and adding the variable inside {} in the TREATAS function solved my issue.
Try this:
VAR __TableVariable= IF( ISFILTERED( 'Product'[Color] ), VALUES( 'Product'[Color] ), { "#all_colors" } ) RETURN CALCULATE( SUM( 'Product Forecast'[Value] ), TREATAS ( {__TableVariable} , 'Product Forecast'[Color] ) )
leomureb
1 year agoMicrosoft Employee
Hi,
I was having the same issue as you and adding the variable inside {} in the TREATAS function solved my issue.
Try this:
VAR __TableVariable=
IF(
ISFILTERED( 'Product'[Color] ),
VALUES( 'Product'[Color] ),
{ "#all_colors" }
)
RETURN
CALCULATE(
SUM( 'Product Forecast'[Value] ),
TREATAS ( {__TableVariable} , 'Product Forecast'[Color] )
)