Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

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

  • Anonymous's avatar
    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's avatar
      Anonymous
      Not applicable

      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.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous ,

       

      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?

       

       

      Or we can try this formula.

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

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        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.

         

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Perhaps LASTNONBLANK ?

     

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      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.

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion
        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.
  • adavbn3's avatar
    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