Forum Discussion
Creating a dynamic filtered table variable
- 8 months ago
Hi CeeJayC,
Thank you for your patience . The issue is that SWITCH and IF in DAX only return scalar values, not tables, which caused the parameter is not the correct type error in your earlier attempts.To resolve this, you need to adjust the logic to switch between complete calculations, such as the results from SUMX, rather than switching between tables.
SWITCH works in this context because it produces scalar values from each SUMX calculation. Each branch uses its own FILTER, so the slicer selection still manages the filtering logic. This approach avoids both the type mismatch error and the “multiple columns cannot be converted to scalar” issue.
Please give it a try and let us know how it goes.
Regards,
Community Support Team.
Hello CPCARDOSO
Thank you for your response! Unfortunately, none of these 3 solutions solved my problem:
IF solution: I ran into the same issue, with the "Parameter is not the correct type" error.
Switch solution: Perhaps I am misunderstanding, but from what I can see the DAX you entered there is exactly what I had submitted that resulted in an error.
Column as Variable solution: Again, this could be a misunderstanding on my part, but Power BI will not allow me to identify a solitary column as a variable to reference later in this way. It wants me to aggregate the column or else it results in an error. This doesn't work because the way I need to reference the column later is in the "Filter" formula and not as an aggregation.
Hello CeeJayC,
The response you are referring to above has been removed for inaccurate information.
Best,
Natalie H.
Community Manager