Forum Discussion

raphael_moreira's avatar
raphael_moreira
Frequent Visitor
8 years ago
Solved

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.

  • 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.

1 Reply

  • 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.