Two data types in the same column

Hi All,

I am creating a dashboard but I need to put two different data types in the same column so
anyone know how this can be done?

Could you provide an example? If what you are referring to is to put for example both a string and an integer data type in the same column, no this is not possible. However depending on what you are trying to do you could convert the column to a string within Dataset creation, but again not sure what your use case is or what type of data you are working with.

Here is a quick example of how I want to do it
image

Hi @lincere -

Here is workaround. I’m hoping there is more elegant way to do this. Disclaimer: This approach will result in a “join explosion” and may not be practical for your use case.

1. Create a measure dataset with 1 row per metric
Both your source dataset and measure dataset need a “link” field. I’m using 1=1.

2. Do a full outer join on the measure dataset

3. Create a calculated field that uses a nested ifelse function to define each metric formula

c_metric

//section 1
ifelse(Section = 1 AND metric="Metric 1",sumOver(Profit,[Section,metric],PRE_AGG),
ifelse(Section = 1 AND metric="Metric 2",sumOver(Sales,[Section,metric],PRE_AGG),
//section 2
ifelse(Section = 2 AND metric="Metric 1",sumOver(Profit,[Section,metric],PRE_AGG)/sumOver(Profit,[],PRE_AGG),
ifelse(Section = 2 AND metric="Metric 2",sumOver(Sales,[Section,metric],PRE_AGG)/sumOver(Sales,[],PRE_AGG),
NULL
))))

4. Create a calculated field that will convert the measure value to a string. This is how you can apply your MM or % formatting. Note: I hope there is a way to round and convert to string (I used a workaround).

c_metric_str

ifelse(Section = 1,concat(toString({c_metric}),"MM"),
ifelse(Section = 2,concat(split(toString({c_metric}*100),".",1),substring(toString({c_metric}*100),locate(toString({c_metric}*100),".",1),3),"%"),
NULL
))

Final Result:

1 Like

It was very useful. Thank you so much!

I am not able to use this solution on charts. is there a way we can use this on visuals as well or we only can apply this to tables.