Forum Discussion
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
Solution 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- sjoerdvn
Solution 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
Solution Sage
Since you're mentioning "power query", in what context are you executing this? maybe send a screenshot?
- DataHero
Helper I
Hi,
here the screeenshot from Power Query:
- sjoerdvn
Solution Sage
Easiest is to use the dialog box when adding the source, or editing the source step.
- sjoerdvn
Solution Sage
It is that reference to an autodate column that is causing the issue here (Table1[DateColumn].[Year])
That will not work here, see the purple box in this article:
https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-auto-date-time- DataHero
Helper I
Hi,
the column isnt the problem.
I tried it with other columns and get the same error.
- DataHero
Helper I
Hi,
this doesnt fix it as the comma is not the cause of the error.
The problem are the ""