In tableau you can write this
WHEN 'Blue' THEN 'B'
WHEN 'Red' THEN 'R'
WHEN 'Green' THEN 'G'
Simply drag the [color] field in color marks card and assign the color for each values that will be easy.
Let us know if this work else share some sample data in packaged workbook.
but i am using SSAS cube datasource, in that case i guess we should write the calculation using the "Calculated Members" option. This is where i am stuck
Sorry never worked on this data source. Can't help
What you have in your example will work as part of a custom SQL statement when you connect to the data source. If you already have the dimensions in the data pane then you will need to use a case statement to present the R, G, B values on a sheet.