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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

MAX(textColumn) how to return the max numeric

I have a table with text column that stores text and numbers.  I have a view that filters the column to ignore the text and show the rows with numbers only.  In that view I want to use the MAX function to return the largest values but since the column is text it yield unwanted results, for example intead of returning 10 it may return 3.  

 

Is it possible to use an agregate function in a text column to yield returns as if it was a numeric column?  I attempted embedding the VALUE and FORMAT function inside the MAX function but that didnt work.

1 ACCEPTED SOLUTION

Try this modified formula which should attempt to extract the number value from a text column and returns blank() if the execution results to an error:

 

Numeric Value =
IF (
    NOT ( ISERROR ( VALUE ( Table[AlphanumericColumn] ) ) ),
    VALUE ( Table[AlphanumericColumn] )
)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu.

View solution in original post

6 REPLIES 6
danextian
Super User
Super User

Hi @Anonymous,

 

I don't think MAX calculation for non-numeric value is possible. I would suggest to create a calculated column to extract the numeric values in your text column. Example:

 

Numeric Value =
IF (
    ISNUMBER ( VALUE ( Table[AlphanumericColumn] ) ),
    VALUE ( Table[AlphanumericColumn] )
)

 

And then use this column to calculate for the max value. 






Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu.
Anonymous
Not applicable

Hi @danextian

 

Thank you for your reply.  I attempeted what you suggested but it complains that it cannot convert value of type Text to type Number.

Image 1589.png

 

 

 

 

 

 

try this

 

column =
if(ticket_change[newvalue] = BLANK() || ticket_change[newvalue] = "", BLANK(),
if(ISNUMBER(VALUE(ticket_change[newvalue])), VALUE(ticket_change[newvalue])))


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Try this modified formula which should attempt to extract the number value from a text column and returns blank() if the execution results to an error:

 

Numeric Value =
IF (
    NOT ( ISERROR ( VALUE ( Table[AlphanumericColumn] ) ) ),
    VALUE ( Table[AlphanumericColumn] )
)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu.
Anonymous
Not applicable

Thank you @danextian.  That worked!  I'm still learning DAX and greatly appreciate the resolution you provided.

Anonymous
Not applicable

This is what I attempted before but didnt work as it was giving me the max value as if it was a text and not a number; returning for MAX(ticket_change_newvalue) the value of 2 and not of 10 as I was expecting.

Estimate = 
FILTER (
    
    SUMMARIZE (
        ticket_change,
        ticket_change[ticket],
        ticket_change[field],
       "hours",MAXX(ticket_change, FORMAT(ticket_change[newvalue],"General Number")), 
       "hours2",MAX(ticket_change[newvalue]), 
       "datetime", MAX  ( ticket_change[datetime] )
    ),
    
    AND ( ticket_change[field] = "timeestimate", ticket_change[ticket]=10984 /*TRIM ( [hours] ) <> ""*/ )
)

 
Image 1590.png

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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