I Published a widget that can probably help you out
https://marketplace.mendix.com/link/component/216495
Data Grid with variable columns. No more list view in list views!
Features
AFAIK it’s not possible to create a truely dynamic table in Mendix, the columns are defined at design time and can be altered/ added at runtime.
Maybe have a look at the pivot table widget from the app store, this might come close to matching your specific requirements