Forum Discussion
Dynamic Filter to change in table DAX Direct Query
The error you're seeing is because you're trying to reference a column directly in a measure without an aggregation function. In DAX, you can't directly reference a column's value without some context, like SUM, MAX, MIN, etc.
To achieve your desired outcome, you can use a combination of measures and calculated columns. But since you're on Direct Query mode, adding a calculated column might not be the best option. So, we'll focus on creating a measure.
First, let's create a measure to capture the selected value from the slicer:
SelectedCompany =
SELECTEDVALUE('YourTableName'[Company_Supplier_Name], "All")
This measure will return the selected company name from the slicer or "All" if nothing is selected.
Now, let's create another measure to determine if the current row should be displayed:
DisplayCompany =
IF(
[SelectedCompany] = "All" || 'YourTableName'[Company_Supplier_Name] = [SelectedCompany],
'YourTableName'[Company_Supplier_Name],
"All Others"
)
Now, you can use this DisplayCompany measure in your table visualization. When you select a company from the slicer, the table will show rows for that company and "All Others". When no company is selected, it will show all companies.
Lastly, to ensure that your table only displays the selected company and "All Others", you might need to adjust the table's filter or visual-level filter to only include rows where the DisplayCompany measure is not blank.