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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
DataHero
Helper I
Helper I

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

1 ACCEPTED SOLUTION
sjoerdvn
Super User
Super User

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

View solution in original post

11 REPLIES 11
sjoerdvn
Super User
Super User

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

sjoerdvn_0-1713513455624.png

 

sjoerdvn
Super User
Super User

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

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

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.

 

Thank you!

sjoerdvn
Super User
Super User

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

Hi,
here the screeenshot from Power Query: 
DataHero_0-1713465921096.png

 

tamerj1
Super User
Super User

Hi @DataHero 
Try to replace all commas "," with semicolons ";"

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

sjoerdvn
Super User
Super User

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

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.