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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Direct Query on a specific case

Hi everyone,

 

Currently, I'm waiting for being able to create a connection with my database. It's on working

 

In waiting , I would like to create a table with the same columns than a table in the database, in order to have some reports. Once the work on the database is done, I will use the direct query. Would my reports will still work well ? Which precaution should I take to avoid errors ?

 

Thank you ! 

 

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

I would use exactly same names as in your database, otherwise all the refrences will be incorrect when you switch

consider this code for setting a type of a column:

= Table.TransformColumnTypes(Source,{{"ColumnA", Int64.Type}})

 in this case when you swtich you need to change Source and "ColumnA".

If you would use the same names as in the database you just need to change Source to reference proper table



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

6 REPLIES 6
Stachu
Community Champion
Community Champion

Working with Direct Query has some limitations which do not apply in the standard setup (see here https://docs.microsoft.com/en-us/power-bi/desktop-use-directquery#limitations-of-directquery). So as long as you don't use any functionalities not supported in Direct Query then you should be fine, and the whole process should be as easy as changing the reference from static table to Direct Query table



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

@Stachu 

Thank you for the answer

 

I will use some DAX functions so it should be fine. Nevertheless, I worry about columns on my static table. 

Does my static table must have same things than the table on the database ? ( the same number of column, the same names)

By example , my static table 

Car has

columnA , columnB

 

and in my database I have the tab

tab_CAR with

CAR_Name, CAR_Year, CAR_Description, Car_Promotion

 

Thanks !

Stachu
Community Champion
Community Champion

I explained similar case here:
https://community.powerbi.com/t5/Desktop/Add-missing-tables-from-data-source-to-existing-dataset/m-p...

I'd create a single connection query (not loaded to the model), that doesn't show any tables, just establishes connection (this way you can easily switch from QA to PROD etc.)
then every table would be referencing that connection query


so in the case I posted it would be instead of this (you need to replace StaticTable and ColumnA:

let 
    Source = StaticTable,
    AddedType = Table.TransformColumnTypes(Source,{{"ColumnA", Int64.Type}})
...

you use this:

let 
    Source = StaticTable,
    AddedType = Table.TransformColumnTypes(Source,{{"CAR_Name", Int64.Type}})
...

the column name is the same as in your database so when you replace StaticTable with a proper one it will work without any more changes



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

Thank you very much !!!

Stachu
Community Champion
Community Champion

I would use exactly same names as in your database, otherwise all the refrences will be incorrect when you switch

consider this code for setting a type of a column:

= Table.TransformColumnTypes(Source,{{"ColumnA", Int64.Type}})

 in this case when you swtich you need to change Source and "ColumnA".

If you would use the same names as in the database you just need to change Source to reference proper table



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

Thank you @Stachu 

I will use the same name to be sure

 

In another case where the names are differents

 

= Table.TransformColumnTypes(Source,{{"ColumnA", Int64.Type}})

When I switch,  columnA is my cible in the static table    and  Source should be  like this ?

= Table.TransformColumnTypes(Name_database{[Schema="dbo",Item="tab_CAR",column="CAR_Name"]}[Data]    ,{{"ColumnA", Int64.Type}})

I'm not sure for the code 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors