Search code examples
powerbipowerbi-desktopcustom-data-type

Power BI How to return a column with different data type summarized


My question is: Is there a way to return a column in a Matrix with different data types to be summarized as shown in the picture?(Using SWITCH) I am not sure if this has been phrased in this way before but hopefully someone knows a simpler solution than what I've tried.

pbix different data type columns

Im trying to return a column in a Matrix with different data types to be summarized. I have tried something similar in transform data to the following.

MixedFormatColumn = SWITCH('Cars'[Attribute],
"Socks",CONVERT('Socks'[Value],STRING) , 
"Paper",FORMAT('Paper'[Value], "#,0.0" ) ,
"Plastics",FORMAT('Plastics'[Value], "$#,0" ) ,
CONVERT('Crayons'[Value],STRING)
)

Although not exact, im sure you get the idea. I just keep getting stuck not sure if its an Power Query or a Measure issue and really not sure how to go about this. If someone could at least point me in the right direction it would be greatly appreciated. Thank you whomever is reading this for your time.


Solution

  • A column or a measure cannot have mixed data types or mixed formatting. In order to get the $ value of socks sold, you would need the $ value for the sale. In order to get a count of socks sold, you would need a number, unless you want to count the rows for socks, but a row might be about more than just one pair of socks.

    Mixing percentages into all this in one single matrix column is not possible. You may want to rethink your approach.