Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Jayrx7
Frequent Visitor

Rounding down an address to the hundred block and IF statement

Hello,

 

I have an address column that I want to round down to the hundred block (EX: 11111 Washington Av to 11100 Washington Av, 123 Washington Av to 100 Washing Av, 1234 Washington Av to 1200 Washington Av and so on). I did some searching and found that the ROUND([field], -2) function works in this case.  

 

I splited the address column by space, and left with a column that mostly have the house numbers but some are texts because of intersection addresses. I tried to do an if statement to round the number to the hundred block if it is a number and return the text if it isn't but my DAX doesn't seem to be working. Its giving this an error message of "Expression that yield variant date-type cannot be used to define calculated columns"

 

Here is my attempt:

Rounded_Address = IF(ISNUMBER([LOCATION - Copy.1]),  ROUND([LOCATION - Copy.1], -2), [LOCATION - Copy.1])
 
Can anyone help with this query or let me know if there is a better approach to tackle this problem?
 
Thank you so much!
1 REPLY 1
rsbin
Super User
Super User

@Jayrx7 ,

The issue is that in Power BI, you cannot have text and numbers in the same column.  This is what is meant by "variant-data type"

If you format everything to a text, your non-numeric addresses will remain.  Your address blocks will just be formatted as text.

Hope you can make this work for you.  If not, please post a small sample of your actual data and we can try to work out an alternate solution.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.