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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
DanielLinda
Helper IV
Helper IV

MAX function with Text column doesn't work in Live Connection SSAS Tabular

Hi Experts,

 

I have a trouble using DAX function: MAX.

I want to get a unique value from Text column to use switch to use different calculation for each category in one measure.

 

In Power BI Desktop not using SSAS Tabular, I could make MAX function with Text column.

 

e.g. Measure = IF(MAX('Table'[TextColumn]) = "A"), Value, Blank())

 

The Table looks like this.

CategoryDateValue
A2019-01-03100
B2019-01-0380
C2020-01-03140
A2020-01-04570
B2020-01-04130
C2020-01-04330

 

However, whenever I use the same function in SSAS Tabular, it makes error with message like this.

 

"the function max takes an argument that evaluates to numbers or dates dax... "

 

I have used MAX function to get unique value from text column in DAX function, but I'm stuck in trouble because it doesn't work in SSAS Tabular.

 

Please give me any idea to solve this issue.

Thanks.

13 REPLIES 13
adavbn3
Frequent Visitor

did you ever find a solution to this? running into the exact problem now, and can't think of a way to workaround it

Greg_Deckler
Super User
Super User

Perhaps LASTNONBLANK ?

 

That's good to know about the MAX function because I use it all the time with text columns.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg,

 

Have you usually used MAX function in Power BI like in my situation as well?

Did you try the same function in SSAS Tabular(SSDT) to make measure in it?

 

When Power BI is connected with SSAS Tabular is the same, it doesn't work MAX function even I make report level measure in Power BI.

No, generally not with SSAS Tabular, just in Power BI Desktop against an imported data set. Although, that is supposed to be SSAS Tabular under the hood so ?

Very strange.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Yes, It is very strange.

I cannot figure out any clue at all that can make different work.

Could you please review below DAX expression.

 

TEST_:=
IF(LASTNONBLANK('FactPayment'[Category], "SUM_PAY_AMT_KRW") , [Payment_KRW (AS-IS)],BLANK())

 

It makes error in SSAS tabular.

 

Thanks in advance.

Anonymous
Not applicable

If you are sure that in the context there'll be only one value anyway... why not use SELECTEDVALUE?

Best
D

@Anonymous 

 

Do you have experience that worked the SELECTEDVALUE function in SSAS?

 

Do you mean my expression: 

 

TEST_:=
IF(MAX('FactPayment'[Category], "SUM_PAY_AMT_KRW") , [Payment_KRW (AS-IS)], BLANK())

 

change into like below...?

IF(SELECTEDVALUE('FactPayment'[Category], "SUM_PAY_AMT_KRW") , [Payment_KRW (AS-IS)], BLANK())

 

I do not have any knowledge with the function, if my expression with SELECTEDVALUE is wrong, please correct it.

 

I tried MAX, LASTNONBLANK, FIRSTNONBLANK... but all of the function made error in SSAS...

 

 

 

Anonymous
Not applicable

Whether you can use this function or not depends on the version of the product you use. Please find the documentation and examples of usage here:

https://dax.guide/selectedvalue/

Best
D
Anonymous
Not applicable

the way you wrote it, you perhaps tried to do this instead

 

e.g. Measure = IF(MAX('Table'[TextColumn]) = "A", Value, Blank())

 

there was an extra ")"

 

don't know if it helps

Anonymous
Not applicable

Hi @DanielLinda ,

 

Based on my test using Power Bi version : 2.80.5803.1061 64-bit .I cannot reproduce your issue here. Could you please update your Power bi desktop and check again?

 

2.PNG

 

Or we can try this formula.

IF(value('Table'[TextColumn]) = "A", Value, Blank())

 

 

Thanks for your kind reproduce with image, Frank.

 

However my issue is when I'm working with SSAS live connect, not just Power BI alone.

The same DAX expression works in Power BI, but when the data comes from SSAS tabular mode in Live connection, the expression makes error.

 

Looks weird.

 

I'm sorry I put wrong express in my post, I surely used correct expression that works in Power BI without SSAS.

like you corrected.

e.g. Measure = IF(MAX('Table'[TextColumn]) = "A", Value, Blank())

 

Therefore, the error is not from ")"

 

Thanks.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Top Solution Authors