You can right click the field in the measures list and set the default number format - you will likely need to use the custom format - it's set up similar to Excel.
Thanks Alex for your response!
But as I said I need a function so that I can change the date format based on user selection from parameters - year, month, quater, hour, minute etc. I'm not looking for a fixed format.
Ah yes. If you can manage the ultimate calculation being a string, you could format it this way. Otherwise you are kind of out of luck.
There's an idea here to ask Tableau to consider adding this:
Thanks Alex.....I'm also waiting for a function like to_char() in Oracle, as part of Tableau. Hopefully it iwll happen soon.