Forum Discussion
rks
Resolver II
2 years agoReturn 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] ) )
rks
Resolver II
2 years agoHi devesh_gupta thank you for the reply!
Changing the measure results in the same behavior.
However, the businesslogic is also wrong, because I don't want to remove the filters from the column, but instead use the value "#all_colors" which holds the forecast data if no products are selected (which is different from the sum of all values).