Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello,
I'll preface this by saying I am an intermediate Excel user who is still relatively new to both M-Code and DAX and I just started using Power BI.
I am currently working on building a query to our P&L statement so that the data is usable in PBI. Our organization uses positive numbers for both our income and expense accounts, which means I need to make all expense lines negative numbers in order to get a correct total on my dashboard. I was able to do this by first creating a column that would return "TRUE" for Income accounts and "FALSE" for Expense accounts (= Table.AddColumn(#"Reordered Columns", "Income/Expense", each if [AccountTypeDescription] = "INCOME" then true else false)).
I then used this column as a backbone in order to transform my data rows, keeping Income accounts positive numbers and changing Expense accounts to negative numbers (= Table.AddColumn(#"Renamed Columns", "4Y Prior Total", each if([#"Income/Expense"]) then [CurrentPeriod_2] else -[CurrentPeriod_2])).
This formula above is working great, however, I have 30 coumns of P&L data that need this transformation (CurrentPeriod_1 - CurrentPeriod_30). This ends up creating 30 additional Applied Steps which might slow down the query and/or be hard to navigate if something breaks.
Is there a way to apply the transformation I need to all 30 columns in one or two applied steps? The formula stays the same for each column except the number after the underscore since the columns are all named CurrentPeriod_## (ex. CP_1, CP_2, CP_3... etc).
Any help or insight would be greatly appreciated! Thank you in advance!
Solved! Go to Solution.
Hi @mramstead1 ,
My first instinct would be to unpivot your [CurrentPeriod_X] columns.
Multi-select all columns that are not [CurrentPeriod_X], then on the Transform tab, go to Unpivot Columns > Unpivot Other Columns.
This will normalise your data for correct data model use, and will mean you only need to perform your polarity change on one column.
Pete
Proud to be a Datanaut!
Hi @mramstead1 ,
My first instinct would be to unpivot your [CurrentPeriod_X] columns.
Multi-select all columns that are not [CurrentPeriod_X], then on the Transform tab, go to Unpivot Columns > Unpivot Other Columns.
This will normalise your data for correct data model use, and will mean you only need to perform your polarity change on one column.
Pete
Proud to be a Datanaut!
Thank you very much @BA_Pete!
Your solution worked great and I now understand how pivoting and unpivoting works within the query (somewhat). Have a great rest of your day!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
8 | |
6 | |
6 | |
6 | |
5 |
User | Count |
---|---|
9 | |
9 | |
8 | |
6 | |
6 |