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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
vinayrk
Regular Visitor

Unable to create SQL DB view

Hi ,

 

I have an sample table which needs to have the following modifications.

 

1) Replace -1 to Null on an column priority column

2)  Change data format to date on Datacreated column

 

While I was able to create these 2.  I'm unable to create the view with Alias prepended into the columns.  Screenshots attached.

 

Any Ideas on how to create an view on the DB end to prepend the alias name to each column.

 

Original Table :

vinayrk_1-1597649575925.png

 

PowerBI Transformation

 

vinayrk_0-1597649544378.png

 

 

Need to recreate the powerbi transformation on the DB end.

1 ACCEPTED SOLUTION

Hi @vinayrk ,

 

Assuming the table name is called "a", then you may type codes like below in the SQL DB.

 

SELECT a.* FROM …


Or


SELECT a.assetId as "a.assetId",
       a.organizationId as "a.organizationId",
       a.dateCreated as "a.dateCreated",
       a.dateModified as "a.dateModified",
       a.installDate as "a.installDate",
       a.manufacturer as "a.manufacturer"
FROM TableA a 
JOIN
     TableB b
ON a. manufacturer = b.manufacturer

For reference:

 

In a join, how to prefix all column names with the table it came from

 

SQL select join: is it possible to prefix all columns as 'prefix.*'?

 

SQL: How do add a prefix to column names in a JOIN?

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@vinayrk , Not very clear

 

In power BI, you can right click and use replace null with any value. https://yodalearning.com/tutorials/learn-how-replace-values-power-query/

 

Do you need the view in DB

create view as

select View1, coalesce(Col1,'NA') from table

 

You can add query of choice in advance option in connection

AdvanceProperty.png

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi Amit, 

 

I'm clear on how to replace values and change data part.   I'm making those changes on the DB side.

 

What im not able to create is an view of the original table with the alias name prepended into each column. 

 

I want to recreate the table structure that was in powerBi on the DB end.  This is how it looks in the current PBI report.

 

// Expand the table to multiple columns, and prepend a table alias to each field name.
TableData = Table.ExpandRecordColumn(SingleColumnTable, "Column1", {
"assetId",
"organizationId",
"dateCreated",
"dateModified",
"installDate",
"manufacturer",
},
{
"a.assetId",
"a.organizationId",
"a.dateCreated",
"a.dateModified",
"a.installDate",
"a.manufacturer",
})

 

We have been asked to make this calculation run on the DB end rather than powerbi.  Our view on the DB end is missing a."column name"  which we are unable to recreate

 

 

Hi @vinayrk ,

 

Assuming the table name is called "a", then you may type codes like below in the SQL DB.

 

SELECT a.* FROM …


Or


SELECT a.assetId as "a.assetId",
       a.organizationId as "a.organizationId",
       a.dateCreated as "a.dateCreated",
       a.dateModified as "a.dateModified",
       a.installDate as "a.installDate",
       a.manufacturer as "a.manufacturer"
FROM TableA a 
JOIN
     TableB b
ON a. manufacturer = b.manufacturer

For reference:

 

In a join, how to prefix all column names with the table it came from

 

SQL select join: is it possible to prefix all columns as 'prefix.*'?

 

SQL: How do add a prefix to column names in a JOIN?

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.