Perspective Table - Date Columns semi-auto formatting

After struggling (unnecessarily) with Date formatting in Perspective Tables, solution in the forum is to manually add the field in the 'columns' property of the table and select your desired format. It works, for fixed data though. I couldn't find a post or comment about my case with a variable dataset anywhere.

I'm binding different dataset tags into the same table based on a dropdown selection of the tags. Then, I came up with this solution.

self.props.columns = [{'field': system.dataset.getColumnHeaders(dataset.value)[y],'render': 'auto', 'numberFormat': '0,0.##', 'dateFormat': 'yyyy-MM-dd'} for y in range(len(system.dataset.getColumnHeaders(dataset.value)))]

It is basically creating the dict (with some of the required keys) for each column in the 'columns' table property based on the number of columns contained in the dataset.

Note that the key 'field' in the dictionary needs to have the column name as value, if not it doesn't works.

Note 2. I'm running the script in the data property binding with a Transform.

I hope this is useful to anyone as it is for me now.

Thanks for sharing.
use the </> button to format the script so it is readable.