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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
WilliamPearson
New Member

SPLIT 2 Years of Data (2021/2022), each on separate columns

 

WilliamPearson_1-1693719604820.png

 

Hello, 

 

I am a beginner with Power BI/Power Query. And I need help with this task: separating data from two columns, into two others.

  • On the first column, "DT_FIM_EXERC", I have two types of dates: 2021 and 2022.
  • On the second column, "$ VL_CONTA", I have the values that I want to split based on their reference date (2021 and 2022).

In the end I would have "DT_FIM_EXERC_2021" next to ""$ VL_CONTA_2021" and "DT_FIM_EXERC_2022" next to "$ VL_CONTA_2022).

 

I would like to know if there's anything I can do to organize my Worksheet in this way by using Power Query's powerful data manipulation. Thanks! 🙂

 

 

1 REPLY 1
Mahesh0016
Super User
Super User

@WilliamPearson I hope this helps you.

Yes, you can definitely use Power Query in Power BI to accomplish this task of separating data from two columns into two other columns based on the values in the "DT_FIM_EXERC" column. Here's a step-by-step guide on how to do this:

1. **Load Your Data:**
- Open your Power BI project.
- Load your data into the Power Query Editor by going to "Home" > "Edit Queries."

2. **Split the Data:**
- In the Power Query Editor, select the table that contains your data.

3. **Add Conditional Columns:**
- Go to the "Add Column" tab.
- Click on "Conditional Column."

4. **Create a Condition for 2021:**
- In the "Conditional Column" dialog, give your new column a name (e.g., "Year_2021").
- For the first condition, choose your "DT_FIM_EXERC" column and set the condition to "equals" 2021.
- In the "Value" box, enter "DT_FIM_EXERC_2021."

5. **Create a Condition for 2022:**
- Click "Add Rule" to add another condition.
- For the second condition, choose your "DT_FIM_EXERC" column and set the condition to "equals" 2022.
- In the "Value" box, enter "DT_FIM_EXERC_2022."

6. **Repeat for the Value Column:**
- Go to the "Add Column" tab again.
- Click on "Conditional Column."
- Create two conditions, similar to what you did for the "DT_FIM_EXERC" column, but this time, use the "$ VL_CONTA" column.
- Name the columns as "$ VL_CONTA_2021" and "$ VL_CONTA_2022" accordingly.

7. **Remove Unnecessary Columns:**
- You can remove the original "DT_FIM_EXERC" and "$ VL_CONTA" columns if you no longer need them.

8. **Close and Apply:**
- Once you have created the new conditional columns and removed the original columns, click the "Close & Apply" button to save your changes and return to Power BI.

Mahesh0016_0-1693815697070.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.