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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
raphael_moreira
Frequent Visitor

Data transformation in Direct Query - PowerBI vs View

Hello.

 

I had a question about performance.

 

I am creating a report using DirectMode. So, I created a View with my query, and I sent it to PowerBI Desktop.

In Power BI, I can do transformations on the columns. Calculations, conditionals, ifs, etc ...

 

But I noticed the following. If I have the following query in my View:

 

select  Id,
           UserId,
           Name,
           Category,
           Date
from TABLE

 

And in PowerBI, make the following transformations:


- Rename the column "Date" to "Date of something important";
- I make an IF in the "Category" column: If NULL then "Undefined", otherwise it, displays the "Category";
- I create a new column called "User", and do a function to concatenate "Id" + "Name";

 

Everything works very well.


But, PowerBI records everything I did on the right panel (steps).

 

If I right click on one of these steps, I have the option to see the "original query" of that transformation. And this query basically did:

 

select Id,
          UserId,
          Name,
          case

              when Category is null then 'Undefined'

              else Category

          end as [Category],
          Date as [Date of something important],
          cast (Id as nvarchar (MAX)) + Name as [User]
from TABLE

 

So, the question is: does PowerBI, in DirectMode, do this SQL for real?

 

Or is it only user-friendly to understand?

 

If it really does that, would not it be better for me to do this in my View first, and then deliver it to PowerBI all formatted?

 

What is the best practice in this scenario?
DirectQuery -> View -> Power BI

 

Performance? Patterns?

 

Thank you.

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

I personally prefer to do the logic in views (if possible) because any business logic change can be done on semantic layer than doing in Power Query and also field name will be same if you use the same view in different reports.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

1 REPLY 1
parry2k
Super User
Super User

I personally prefer to do the logic in views (if possible) because any business logic change can be done on semantic layer than doing in Power Query and also field name will be same if you use the same view in different reports.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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