<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Issue with table names having spaces in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-table-names-having-spaces/m-p/3879976#M151464</link>
    <description>&lt;P&gt;Hi There,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The below code works totally fine when the table name is single word. If the table name has any spaces it is throwing error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import json&lt;BR /&gt;import requests&lt;/P&gt;&lt;P&gt;# Replace with your Power BI tenant ID and client ID and client secret&lt;BR /&gt;tenant_id = ''&lt;BR /&gt;client_id = ''&lt;BR /&gt;client_secret = ''&lt;BR /&gt;# Workspace ID&lt;BR /&gt;workspace_id = ''&lt;BR /&gt;# Dataset ID&lt;BR /&gt;dataset_id = ''&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# OAuth2 endpoint for token acquisition&lt;BR /&gt;token_url = f'&lt;A href="https://login.microsoftonline.com/{tenant_id}/oauth2/token" target="_blank"&gt;https://login.microsoftonline.com/{tenant_id}/oauth2/token&lt;/A&gt;'&lt;BR /&gt;# Request body for token acquisition&lt;BR /&gt;token_data = {&lt;BR /&gt;'grant_type': 'client_credentials',&lt;BR /&gt;'client_id': client_id,&lt;BR /&gt;'client_secret': client_secret,&lt;BR /&gt;'resource': '&lt;A href="https://analysis.windows.net/powerbi/api" target="_blank"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;'&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;# Request token from Azure&lt;BR /&gt;token_response = requests.get(token_url, data=token_data)&lt;BR /&gt;token_response_data = token_response.json()&lt;/P&gt;&lt;P&gt;# Check for token acquisition errors&lt;BR /&gt;if token_response.status_code != 200:&lt;BR /&gt;print({'statusCode': 500,&lt;BR /&gt;'body': json.dumps({'error': token_response_data.get('error', 'Failed to acquire token')})})&lt;/P&gt;&lt;P&gt;# Get access token&lt;BR /&gt;access_token = token_response_data['access_token']&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;api_url = f'&lt;A href="https://api.powerbi.com/v1.0/myorg/groups/{workspace_id}/datasets/{dataset_id}/executeQueries" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg/groups/{workspace_id}/datasets/{dataset_id}/executeQueries&lt;/A&gt;'&lt;/P&gt;&lt;P&gt;# HTTP headers with authorization&lt;BR /&gt;headers = {&lt;BR /&gt;'Authorization': f'Bearer {access_token}',&lt;BR /&gt;'Content-Type': 'application/json'&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;payload = {&lt;BR /&gt;"queries": [&lt;BR /&gt;{&lt;BR /&gt;"query": "Evaluate 'Users'"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"serializerSettings": {&lt;BR /&gt;"includeNulls": False&lt;BR /&gt;},&lt;BR /&gt;"impersonatedUserName": "&amp;lt;your_user&amp;gt;@&amp;lt;your_domain&amp;gt;.com"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;response = requests.post(api_url, headers=headers, json=payload)&lt;BR /&gt;print(response.text)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pass Scenario:&amp;nbsp;"query": "Evaluate 'Users'"&lt;/P&gt;&lt;P&gt;Fail Scenario:&amp;nbsp;"query": "Evaluate 'Report views'"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know how we can pass the table names which has spaces.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Laxmikanth&lt;/P&gt;</description>
    <pubDate>Tue, 30 Apr 2024 15:02:30 GMT</pubDate>
    <dc:creator>Laxmikanth</dc:creator>
    <dc:date>2024-04-30T15:02:30Z</dc:date>
    <item>
      <title>Issue with table names having spaces</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-table-names-having-spaces/m-p/3879976#M151464</link>
      <description>&lt;P&gt;Hi There,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The below code works totally fine when the table name is single word. If the table name has any spaces it is throwing error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import json&lt;BR /&gt;import requests&lt;/P&gt;&lt;P&gt;# Replace with your Power BI tenant ID and client ID and client secret&lt;BR /&gt;tenant_id = ''&lt;BR /&gt;client_id = ''&lt;BR /&gt;client_secret = ''&lt;BR /&gt;# Workspace ID&lt;BR /&gt;workspace_id = ''&lt;BR /&gt;# Dataset ID&lt;BR /&gt;dataset_id = ''&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# OAuth2 endpoint for token acquisition&lt;BR /&gt;token_url = f'&lt;A href="https://login.microsoftonline.com/{tenant_id}/oauth2/token" target="_blank"&gt;https://login.microsoftonline.com/{tenant_id}/oauth2/token&lt;/A&gt;'&lt;BR /&gt;# Request body for token acquisition&lt;BR /&gt;token_data = {&lt;BR /&gt;'grant_type': 'client_credentials',&lt;BR /&gt;'client_id': client_id,&lt;BR /&gt;'client_secret': client_secret,&lt;BR /&gt;'resource': '&lt;A href="https://analysis.windows.net/powerbi/api" target="_blank"&gt;https://analysis.windows.net/powerbi/api&lt;/A&gt;'&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;# Request token from Azure&lt;BR /&gt;token_response = requests.get(token_url, data=token_data)&lt;BR /&gt;token_response_data = token_response.json()&lt;/P&gt;&lt;P&gt;# Check for token acquisition errors&lt;BR /&gt;if token_response.status_code != 200:&lt;BR /&gt;print({'statusCode': 500,&lt;BR /&gt;'body': json.dumps({'error': token_response_data.get('error', 'Failed to acquire token')})})&lt;/P&gt;&lt;P&gt;# Get access token&lt;BR /&gt;access_token = token_response_data['access_token']&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;api_url = f'&lt;A href="https://api.powerbi.com/v1.0/myorg/groups/{workspace_id}/datasets/{dataset_id}/executeQueries" target="_blank"&gt;https://api.powerbi.com/v1.0/myorg/groups/{workspace_id}/datasets/{dataset_id}/executeQueries&lt;/A&gt;'&lt;/P&gt;&lt;P&gt;# HTTP headers with authorization&lt;BR /&gt;headers = {&lt;BR /&gt;'Authorization': f'Bearer {access_token}',&lt;BR /&gt;'Content-Type': 'application/json'&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;payload = {&lt;BR /&gt;"queries": [&lt;BR /&gt;{&lt;BR /&gt;"query": "Evaluate 'Users'"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"serializerSettings": {&lt;BR /&gt;"includeNulls": False&lt;BR /&gt;},&lt;BR /&gt;"impersonatedUserName": "&amp;lt;your_user&amp;gt;@&amp;lt;your_domain&amp;gt;.com"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;response = requests.post(api_url, headers=headers, json=payload)&lt;BR /&gt;print(response.text)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pass Scenario:&amp;nbsp;"query": "Evaluate 'Users'"&lt;/P&gt;&lt;P&gt;Fail Scenario:&amp;nbsp;"query": "Evaluate 'Report views'"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know how we can pass the table names which has spaces.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Laxmikanth&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 15:02:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-table-names-having-spaces/m-p/3879976#M151464</guid>
      <dc:creator>Laxmikanth</dc:creator>
      <dc:date>2024-04-30T15:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with table names having spaces</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-table-names-having-spaces/m-p/3880709#M151489</link>
      <description>&lt;P&gt;&lt;A href="https://pythonexamples.org/python-string-escape-single-quote/" target="_blank"&gt;Python String – Escape single quote (pythonexamples.org)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 22:11:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-table-names-having-spaces/m-p/3880709#M151489</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-04-30T22:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with table names having spaces</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-table-names-having-spaces/m-p/3895767#M151822</link>
      <description>&lt;P&gt;Hi There,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the update.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The 2nd method in the article mentions to enclose single quotes in double quotes and it has been done. It worked for the one worded table but doesn't work for the table names which have spaces.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pass Scenario:&amp;nbsp;"query": "Evaluate 'Users'"&lt;/P&gt;&lt;P&gt;Fail Scenario:&amp;nbsp;"query": "Evaluate 'Report views'"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Laxmikanth&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 14:38:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-table-names-having-spaces/m-p/3895767#M151822</guid>
      <dc:creator>Laxmikanth</dc:creator>
      <dc:date>2024-05-06T14:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with table names having spaces</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-table-names-having-spaces/m-p/3895776#M151824</link>
      <description>&lt;P&gt;Shouldn't it be&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"query": "Evaluate "'"Report views"'""&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 14:41:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Issue-with-table-names-having-spaces/m-p/3895776#M151824</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-05-06T14:41:58Z</dc:date>
    </item>
  </channel>
</rss>

