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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
dashmarley11
Helper I
Helper I

Extracting Specific Values from a Table and Insert them into New table

I have a table with rates where all of the data is in one row:

Rate001moRate002moRate003moRate004moRate005mo
.065.075.055.040.035

 

I want to create a new table that looks like this:

TermRate
1.065
2.075
3.055
4.040
5.035
2 ACCEPTED SOLUTIONS
jgeddes
Super User
Super User

That is pretty straightforward in Power Query. The following code should work. Create a blank query and paste this code into the advanced editor, changing the source to equal the query that has your data in the single row.

let
    Source = NameOfTheQueryThatHasTheData,
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {}, "Term", "Rate"),
    #"Transform Text" = Table.TransformColumns(#"Unpivoted Columns",{{"Term", each Text.TrimStart(Text.Select(_,{"0".."9"}), "0"), type text}})
in
    #"Transform Text"

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

jgeddes
Super User
Super User

Unpivoting is a pretty helpful function and can be used on any table in power query.

After the unpivot step the code is extracting the numbers from the column with the header names and removing the leading zeros.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

3 REPLIES 3
jgeddes
Super User
Super User

Unpivoting is a pretty helpful function and can be used on any table in power query.

After the unpivot step the code is extracting the numbers from the column with the header names and removing the leading zeros.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





jgeddes
Super User
Super User

That is pretty straightforward in Power Query. The following code should work. Create a blank query and paste this code into the advanced editor, changing the source to equal the query that has your data in the single row.

let
    Source = NameOfTheQueryThatHasTheData,
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {}, "Term", "Rate"),
    #"Transform Text" = Table.TransformColumns(#"Unpivoted Columns",{{"Term", each Text.TrimStart(Text.Select(_,{"0".."9"}), "0"), type text}})
in
    #"Transform Text"

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





@jgeddes Thank you!  I have no idea how that worked but it does.  Can that only be done from a base query, or can that also be accomplished by using a Data Set?

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.