Forum Discussion

jersey417's avatar
jersey417
Helper I
4 years ago

Snowflake's Query_tag functionality in Power Query?

I'm currently trying to implement Snowflake's Query_Tag functionality within a number of reports to start tracking associated costs down to the workspace/report level.  I'm able to implement the following in Snowflake's Worksheets and the query run successfully. The query tag is loaded as expected in Snowflakes history query tag field. 

 

Example of the SQL currently being used;

---

ALTER SESSION SET QUERY_TAG = 'Workspace - Report';

SELECT  * 

FROM View

--- 

 

However, when I try to load the following SQL into the snowflake connector I get the following error.

 

I'd like to understand how to implement this via a native connect if possible. Has anyone had success getting this to work? 

 

 

10 Replies

  • I'am interested too. I tried to pass an ALTER SESSION statement in the connection (with or without semicolon) :

     

     

    But I have this error : Expression.Error: Native queries aren't supported by this value.

    However I have a query in my Snowflake account 

    I don't understant why Power BI encapsulate my query in a select * FROM ?

  • I had this same issue and wanted to track the cost of the PBI reports. I couldnt get the actual QUERY_TAG to work however a workaround we are doing is adding the query tag statement at the end of the query as a comment and then parsing out the QUERY_TEXT from ACCOUNT_USAGE to get the usage of the report. Hope that helps

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jersey417 ,

     

    1.It may casued by the semicolon in the end of the query,please delete it.

    2. Please try YMadden 's suggestion provided in this thread: Fully qualifying the table names as dbname.schemaname.tablename

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Anonymous 

     

    Thanks - Both of those options are not resolving the issue.  When we move the semicolon it causes additional errors. 

     

  • scottdigs's avatar
    scottdigs
    Frequent Visitor

    I'm also interested in a solution for this for tracking reporting costs. In Tableau we can use 'Initial SQL' to accomplish this. However, Power BI seems to lack this functionality.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Did anybody get this to work?

    • jersey417's avatar
      jersey417
      Helper I

      No - The Snowflake connector needs to be updated to allow for the following.

  • We have successfully determined how to calculate credit consumption for each Power BI dataset run against the Snowflake database. With the recent Power BI release, we observed that the query tag column in the Snowflake usage history table is now being updated. This column includes a unique activity ID that remains consistent across all tables triggered from the dataset. By leveraging this unique activity ID, we can group all related queries and accurately determine the credits consumed for each run.

     

     

     

    • jeffshieldsdev's avatar
      jeffshieldsdev
      Solution Sage

      How do you connect the ActivityId you see in Snowflake's Query Tag column to a Semantic Model refresh? The Semantic Model refresh has RequestId--I can't find how to bridge the two IDs. Could you share how you accomplished this? Thank you.