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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Uspace87
Resolver III
Resolver III

Run Dax query in Fabric Notebook

Hi all,
 
I hope someone can help me :).
 
I am running a trace on a dataset using Fabric Notebook (Python).
Basically meanwhile the trace is running I refresh the report and I get as a result all the queries that got sent.
 
I will paste some of the code here with some comments
 
 
query1 = final_trace_logs.iloc[0]['Text Data'] (Here I store the dax query into variable query1)
 
print(query1) (here I print it and it looks good and if I copy paste the result and I run in on dax studio it works)
 
The next step is where I have problems. I don't undestand why if I paste the query as a string it works, if I pass it as a variable, the code gives me error. can someone help me please?
 
test = fabric.evaluate_dax( "Validation Test Hive", query1) 
 
7 REPLIES 7
Anonymous
Not applicable

Hi @Uspace87 ,

Thanks for using Fabric Community.
I haven't tried it, can you please try like this?

query1 = 'final_trace_logs.iloc[0]['Text Data']'

or 

query1 = "final_trace_logs.iloc[0]['Text Data']"

 
Please let me know if you got any errors?

Anonymous
Not applicable

Hello @Uspace87 ,

We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet .
In case if you have any resolution please do share that same with the community as it can be helpful to others .
Otherwise, will respond back with the more details and we will try to help .

hi @Anonymous  thank you for your reply but that would not work.

 

as I mentioned before I do store the the dax code into the variable query1

 

query1 = final_trace_logs.iloc[0]['Text Data']

Anonymous
Not applicable

Hi @Uspace87 ,

Syntax of evaluate_dax - sempy.fabric package | Microsoft Learn
It expects string

vgchennamsft_1-1715334751251.png


For Eg: Read data from semantic models and write data that semantic models can consume - Microsoft Fabric | ...

vgchennamsft_3-1715334803377.png


Can you please check the type(query1) ? I can see it is not a string.

Hope this is helpful. Please let me know incase of further queries

 

Uspace87_0-1716560511369.png

Hi @Anonymous  thanks for the replay. as you can see in the output I am printing the dax query and the type of the variable (query) and it's a string but if I pass it as a variable the code does not work, I have to copy and paste the text itself as you did in your example

 

Anonymous
Not applicable

Hi @Uspace87 ,

Can you please share the screenshot for below codes -

query1 = final_trace_logs.iloc[0]['Text Data']
print(query1)

 

final_trace_logs.iloc[0]['Text Data']

 

print(type(query1))

 
I can get some more idea of your problem and I can help you out.

Anonymous
Not applicable

Hello @Uspace87 ,

We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet .
In case if you have any resolution please do share that same with the community as it can be helpful to others .
Otherwise, will respond back with the more details and we will try to help .
Thanks

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.