Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

New Member

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






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! 🙂



Solution Sage
Solution Sage

@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.



Helpful resources

PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors