Forum Discussion
Convert column into measure
- 4 years ago
I eventually figured out a solution, which is a bit of a workaround unfortunately. In Power Query, I first created a Custom Column that shows me number of characters in the ZIP column:
Then I was able to create a query that adds the leading zero if the length was less than 5:
Hi,
I am not sure how your desired outcome of the visualization looks like, but please try the below whether it suits your requirement.
RealZipCode =
SWITCH (
TRUE (),
LEN ( SELECTEDVALUE ( 'Table'[ZipCode] ) ) = 5, SELECTEDVALUE ( 'Table'[ZipCode] ),
LEN ( SELECTEDVALUE ( 'Table'[ZipCode] ) ) = 4, "0" & SELECTEDVALUE ( 'Table'[ZipCode] ),
LEN ( SELECTEDVALUE ( 'Table'[ZipCode] ) ) = 3, "00" & SELECTEDVALUE ( 'Table'[ZipCode] )
)
Hello Jihwan,
I tried this and it doesn't work. I was able to enter the formula without problems but when I check the RealZipCode measure, it doesn't populate the map at all. Any ideas why this is the case? Thanks.
- Jihwan_Kim4 years agoSuper User
Hi,
I am not 100% sure without seeing your pbix file, but please try to check data type and category type of your column.
I suggest searching "power bi column category type zip code" in Edge or Google.
Thanks.
- dantyson804 years agoFrequent Visitor
The Data category is "Postal code" for ZipCode. I don't think I can send the file due to a large amount of sensitive information. Are there additional screenshots that might help?
- dantyson804 years agoFrequent Visitor
Can anyone provide further assistance? I'm still amazed how seemingly difficult it is to get DAX to recognize a column as a measure. Unbelievable.