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
pallavisave7
Frequent Visitor

If Condition for Text not recognizing column name

I have a text column USERID for which I want to determine part of a USERID based on IF condition. However, I tried as both column and measure, but getting error "can not find column, please use aggregate function". How do I apply aggregate function on text column? I need to work in DirectQuery mode only.

pallavisave7_0-1637412001387.png

 

1 ACCEPTED SOLUTION

Hi, @pallavisave7 

According to your DAX formula and error message, it seems that the problem occurs because of one missing parenthesis in the function LEN(MAX('Sessions'[Known Visitor Id]):

vrobertqmsft_0-1637658773683.png

 

I suggest you to change the DAX formula like this and check if the problem can disappear:

Known Visitor Id = 

RIGHT(MAX('Sessions'[Known Visitor Id]),LEN(MAX('Sessions'[Known Visitor Id])) - FIND("\",MAX('Sessions'[Known Visitor Id])))

 

And you can get what you want.

 

If you still have a problem, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
jeroendekk
Resolver IV
Resolver IV

Hi @pallavisave7 
Indeed MAX will not work with text. I am not sure about the expected result but you could try FIRSTNONBLANKVALUE, which is an aggregation that works on text columns and gives (like the name implies) the first value.

Best regards,

 

Jeroen

@jeroendekk 

FYI:

VahidDM_0-1637448940109.png

 

😎

 

Oops sorry, apparently you can. Learned something new thanks!

Hi, @pallavisave7 

Glad to hear that you have solved your problem with the help of VahidDM, would you like to mark his reply as a solution so that others can learn from it too?

Thanks in advance!

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@VahidDM 

I tried 

Known Visitor Id = RIGHT(MAX('Sessions'[Known Visitor Id]),LEN(MAX('Sessions'[Known Visitor Id]) - FIND("\",MAX('Sessions'[Known Visitor Id]))))
 
However I am getting error: 
pallavisave7_0-1637604520664.png

 

 

Hi @pallavisave7 

 

Try this:

Known Visitor Id =
RIGHT (
    MAX ( 'Sessions'[Known Visitor Id] ),
    LEN ( MAX ( 'Sessions'[Known Visitor Id] ) )
        - FIND ( "\", MAX ( 'Sessions'[Known Visitor Id] ) )
)

 

If it doesn't work, then please share a sample of your data.

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Hi, @pallavisave7 

According to your DAX formula and error message, it seems that the problem occurs because of one missing parenthesis in the function LEN(MAX('Sessions'[Known Visitor Id]):

vrobertqmsft_0-1637658773683.png

 

I suggest you to change the DAX formula like this and check if the problem can disappear:

Known Visitor Id = 

RIGHT(MAX('Sessions'[Known Visitor Id]),LEN(MAX('Sessions'[Known Visitor Id])) - FIND("\",MAX('Sessions'[Known Visitor Id])))

 

And you can get what you want.

 

If you still have a problem, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

VahidDM
Super User
Super User

Hi @pallavisave7 

 

Use MAX(Sessions[column name] in the measure.

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Hello @VahidDM,

Thank you for your response, but when I try putting aggreagte function like MAX(Sessions[column name]) I get error 'can not convert value of type text to Number'. 

I need to work in DirectQuery mode only.

 pallavisave7_0-1637432461220.png

I believe to apply aggregate function it needs to be numberic data, however my column contains text.

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.

Top Solution Authors