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
evvvb7
Regular Visitor

Creating a new table help

Hello! Please help - I have a situation where my data source has 1 row of sales data and separate columns identifying the the types of product. The issue is I need to display analytics based on the Product Type summarizing the Amount of each Product Type sold. I need to create a new table, I beleive, to achieve this so Product Type is in a singular column, so that there is multiple rows for each sale #, one for each Product Type. Such as transforming this sample data:

 

Sale #AmountProduct AProduct  BProduct CProduct D
1200,000YesNoNoNo
215,000NoYesYesNo
322,000YesNoYesYes

 

To this:

 

Sale #AmountProduct Type
1200,000Product A
215,000Product B
215,000Product C
322,000Product A
322,000Product C
322,000Product D
3 ACCEPTED SOLUTIONS
kpost
Super User
Super User

-Click"Transform Data" to open Power Query and modify the table

 

-Highlight the first two columns "Sale #" and "Amount", then right click and select "Unpivot other columns"

 

- Filter the "Yes/No" column on the "Yes" value.

 

See below screenshot, and I have also attached a .pbix file where I solved your problem.

solution.PNG

///Mediocre Power BI Advice, but it's free///

View solution in original post

Yes, if you want to keep the original dataset untouched, then BEFORE you do the steps I outlined, duplicate the original table.  Make your modifications to the duplicate.

duplicate.PNG

View solution in original post

Assuming you want to have two copies of this table in your dataset, namely the original and the transformed one per your question:

 

Add the table to your dataset, Duplicate it, do the transformations I described in the Solution on the duplicated version.

 

This will leave you with two copies of the table.  One transformed per your question, and the other left untouched.  Both will query the original source, and both will update when the source document is updated and you refresh your dataset.

View solution in original post

8 REPLIES 8
kpost
Super User
Super User

-Click"Transform Data" to open Power Query and modify the table

 

-Highlight the first two columns "Sale #" and "Amount", then right click and select "Unpivot other columns"

 

- Filter the "Yes/No" column on the "Yes" value.

 

See below screenshot, and I have also attached a .pbix file where I solved your problem.

solution.PNG

///Mediocre Power BI Advice, but it's free///

Thank you! This certainly does what i was looking for.

 

Is there a way of doing this without changing the original dataset? Such as creating a table rather than overriding the table? Perhaps as a query so when data is updated it automatically updates?

Yes, if you want to keep the original dataset untouched, then BEFORE you do the steps I outlined, duplicate the original table.  Make your modifications to the duplicate.

duplicate.PNG

Thanks for providing more insight and apologies for delay on my response (weekend)...

 

Is there a way I could have the "unpivot columns" do its things upon updating a dataset? If the underlying data gets refreshed, this unpivot function automatically updates the new table we created for this scenario? Would it be a query as opposed a table creation?

Anything you do in Power Query will automatically be executed when you update the dataset.  It's baked into the 'refresh'.

 

In the case of a 'Duplicate' operation in Power Query, I believe the first step for both tables is to query the original source before doing any transformations.

So query the first table, and then do the unpivot columns off the querried table?

Assuming you want to have two copies of this table in your dataset, namely the original and the transformed one per your question:

 

Add the table to your dataset, Duplicate it, do the transformations I described in the Solution on the duplicated version.

 

This will leave you with two copies of the table.  One transformed per your question, and the other left untouched.  Both will query the original source, and both will update when the source document is updated and you refresh your dataset.

Awesome, thanks for your expertise!

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.