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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
fabiolamelo
Helper II
Helper II

How to separate the salary amount from the range in a different column

Hi everyone,

I have a table with a number of salaries and a range of it. I am trying to find a way to separate the salary amount from the range in different tables.

 

This is the table now

City                        IdCountry            Salary and Range             

 Canberra            ACT                        61          

 Canberra            ACT                        56 - 66  

 Sydney                 NSW                      56          

 Sydney                 NSW                      51 - 61  

 Regional              NSW                      48 - 65  

 Regional              NSW                      55          

 Darwin                 NT                          51          

 Darwin                 NT                          46 - 57  

 

I would like the table to return this

City                        IdCountry            Range of Salary       Salaries

Canberra             ACT                        56 - 66                      61

Sydney                 NSW                      51 - 61                      56

Regional               NSW                      48 - 65                      55

Darwin                  NT                          46 - 57                      51

 

Is there a way to solve this problem?

Many thanks in advance for your support

Fabi Melo

2 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@fabiolamelo start a blank query and click advanced editor and paste this M code and see if that is what you need

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WOrTAOTEvKbWoKPHQAghU0lGCMSFQwdE5BE0ElYtFn4KZIVY1sTq0s9LUTEFXwcwMyZ7gypS81EoFHBqQtPoFh+O1Ck0f0Co8vqOdrYYgDxoiWRWUmp6Zn5eYg9cmgvagB6SJBcgeU5rbY2qKJxRdEovKM/OICcUQLIJ4ghEemANouQkoqZqaQ2yMBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [City = _t, IdCountry = _t, #"Salary and Range" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"City", type text}, {"IdCountry", type text}, {"Salary and Range", type text}}),
    #"Trimmed Text" = Table.TransformColumns(#"Changed Type",{{"City", Text.Trim, type text}, {"IdCountry", Text.Trim, type text}, {"Salary and Range", Text.Trim, type text}}),
    #"Added Custom" = Table.AddColumn(#"Trimmed Text", "Flag", each Text.PositionOf([Salary and Range],"-")),
    #"Filtered Range" = Table.SelectRows(#"Added Custom", each ([Flag] <> -1)),
    #"Filtered Salary" = Table.SelectRows(#"Added Custom", each ([Flag] = -1)),
    #"Merged Queries" = Table.NestedJoin(#"Filtered Salary", {"City", "IdCountry"}, #"Filtered Range", {"City", "IdCountry"}, "Salary Range", JoinKind.LeftOuter),
    #"Expanded Salary Range" = Table.ExpandTableColumn(#"Merged Queries", "Salary Range", {"Salary and Range"}, {"Salary and Range.1"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Salary Range",{{"Salary and Range", "Salary"}, {"Salary and Range.1", "Range"}}),
    #"Removed Columns" = Table.RemoveColumns(#"Renamed Columns",{"Flag"})
in
    #"Removed Columns"

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



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

amitchandak
Super User
Super User

@fabiolamelo , split the column by delimiter, Trim the space and then add two new columns and take Avg

https://www.tutorialgateway.org/how-to-split-columns-in-power-bi/

in M

=([col1]+[col2])/2

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

View solution in original post

3 REPLIES 3
ryan_mayu
Super User
Super User

@fabiolamelo 

 

Maybe you can try below meausre to create a new table

Table 2 = SUMMARIZE(Sheet2,Sheet2[City],Sheet2[IdCountry],"value",MAX(Sheet2[range]))

1.PNG

Hope this is helpful.





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

Proud to be a Super User!




amitchandak
Super User
Super User

@fabiolamelo , split the column by delimiter, Trim the space and then add two new columns and take Avg

https://www.tutorialgateway.org/how-to-split-columns-in-power-bi/

in M

=([col1]+[col2])/2

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
parry2k
Super User
Super User

@fabiolamelo start a blank query and click advanced editor and paste this M code and see if that is what you need

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WOrTAOTEvKbWoKPHQAghU0lGCMSFQwdE5BE0ElYtFn4KZIVY1sTq0s9LUTEFXwcwMyZ7gypS81EoFHBqQtPoFh+O1Ck0f0Co8vqOdrYYgDxoiWRWUmp6Zn5eYg9cmgvagB6SJBcgeU5rbY2qKJxRdEovKM/OICcUQLIJ4ghEemANouQkoqZqaQ2yMBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [City = _t, IdCountry = _t, #"Salary and Range" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"City", type text}, {"IdCountry", type text}, {"Salary and Range", type text}}),
    #"Trimmed Text" = Table.TransformColumns(#"Changed Type",{{"City", Text.Trim, type text}, {"IdCountry", Text.Trim, type text}, {"Salary and Range", Text.Trim, type text}}),
    #"Added Custom" = Table.AddColumn(#"Trimmed Text", "Flag", each Text.PositionOf([Salary and Range],"-")),
    #"Filtered Range" = Table.SelectRows(#"Added Custom", each ([Flag] <> -1)),
    #"Filtered Salary" = Table.SelectRows(#"Added Custom", each ([Flag] = -1)),
    #"Merged Queries" = Table.NestedJoin(#"Filtered Salary", {"City", "IdCountry"}, #"Filtered Range", {"City", "IdCountry"}, "Salary Range", JoinKind.LeftOuter),
    #"Expanded Salary Range" = Table.ExpandTableColumn(#"Merged Queries", "Salary Range", {"Salary and Range"}, {"Salary and Range.1"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Salary Range",{{"Salary and Range", "Salary"}, {"Salary and Range.1", "Range"}}),
    #"Removed Columns" = Table.RemoveColumns(#"Renamed Columns",{"Flag"})
in
    #"Removed Columns"

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors