Forum Discussion

DataHero's avatar
DataHero
Icon for Helper I rankHelper I
2 years ago
Solved

DAX Queries dont recognize apostroph ""

Hi together,

 

currently Im exploring DAX Queries with SSAS conncetor.

However, it seems that I cant use "" to name columns.

This is very strange because apostroph is used in all youtube videos I saw about this topic.


DEFINE
MEASURE Table1[M1] = SUM ( Table1[Column1] )

EVALUATE
SUMMARIZECOLUMNS (
Table1[DateColumn].[Year],
"TestName", [M1]                                                             --> here is the error
)

error message: expected token ","

When I write TestName between the apostrophs, Power Query Intellisense is turning on.
So, it seems that PQ thinks that I want to write a formula here.

Note: Im in Germany , Model language is set to English (USA), DAX formatting is set to standard.

Thanks for any help.

Kind regards

  • Ah, Ok, Now I understand what you are trying to do. The quotes need escaping, by using two double quotes instead of one. See my examply below.

    let
        Source = AnalysisServices.Database("powerbi://api.powerbi.com/v1.0/myorg/xxxxxxxxxxxxxxx", "yyyyyyyyyy", [Query="EVALUATE#(lf)SUMMARIZECOLUMNS(#(lf)'date'[nr year]#(lf),""# ap"", [# active policies]#(lf))", Culture="nl-NL"])
    in
        Source

11 Replies

  • sjoerdvn's avatar
    sjoerdvn
    Icon for Solution Sage rankSolution Sage

    Ah, Ok, Now I understand what you are trying to do. The quotes need escaping, by using two double quotes instead of one. See my examply below.

    let
        Source = AnalysisServices.Database("powerbi://api.powerbi.com/v1.0/myorg/xxxxxxxxxxxxxxx", "yyyyyyyyyy", [Query="EVALUATE#(lf)SUMMARIZECOLUMNS(#(lf)'date'[nr year]#(lf),""# ap"", [# active policies]#(lf))", Culture="nl-NL"])
    in
        Source
    • DataHero's avatar
      DataHero
      Icon for Helper I rankHelper I

      Thank you sjoerdvn ,
      this solved it! Just to understand it, can you explain why I need double quotes instead of one?

      • sjoerdvn's avatar
        sjoerdvn
        Icon for Solution Sage rankSolution Sage

        The dax query is part of the Power Query code and should start and end with a double quote; so when the dax query itself contains a double quote character, Power query thinks that is where the dax query ends. To be able to tell the difference between a double quote within the dax query, and a double quote ending the dax query, an "escape sequence" is used for double quotes within the dax query.
        Escaping is a common thing in computer science.

         

  • sjoerdvn's avatar
    sjoerdvn
    Icon for Solution Sage rankSolution Sage

    Since you're mentioning "power query", in what context are you executing this? maybe send a screenshot?

    • DataHero's avatar
      DataHero
      Icon for Helper I rankHelper I

      Hi,
      here the screeenshot from Power Query: 

       

  • sjoerdvn's avatar
    sjoerdvn
    Icon for Solution Sage rankSolution Sage

    Easiest is to use the dialog box when adding the source, or editing the source step.

     

    • DataHero's avatar
      DataHero
      Icon for Helper I rankHelper I

      Hi,
      the column isnt the problem.
      I tried it with other columns and get the same error.

    • DataHero's avatar
      DataHero
      Icon for Helper I rankHelper I

      Hi,
      this doesnt fix it as the comma is not the cause of the error.
      The problem are the ""