Forum Discussion
Sort multiple tables using dax
I don't have a button table just three separate buttons
If you have three separate buttons and not a dedicated table, you can still achieve the dynamic sorting using a DAX measure. Assuming you have individual slicers or buttons for "Registered at," "Started at," and "Completed at," you can create a DAX measure to dynamically determine the sorting order. Here's how you can modify the measure:
SortOrder =
SWITCH(
TRUE(),
VALUES('YourTable'[Registered at]), [Learner ID],
VALUES('YourTable'[Started at]), [Started at],
VALUES('YourTable'[Completed at]), [Completed at]
)
In this example, replace 'YourTable' with the actual name of your table. This measure works by checking which column is in the filter context based on the selected button and then uses that column for sorting.
Follow the steps from the previous response to create a SortColumn in your table and use it for sorting in the table visualization. The sorting will dynamically switch between columns based on the selected button.
This approach assumes that only one button is selected at a time. If you have multiple buttons selected simultaneously, you may need to adjust the logic accordingly.