How to do Rows calculation & Data cleaning Using Power Query in Power BI Tool | Power Query Explained
Power Query is a data transformation and data preparation tool
that is part of Microsoft Excel and Power BI (Business Intelligence)
applications. It allows users to connect to various data sources, transform and
shape the data, and load it into Excel, Power BI, or other data analysis tools
for further analysis and reporting.
In this post, we are going to look at how can we do row calculations in the Power Query.
I took a simple Excel sheet to showcase this
First of all, we upload an Excel file to Power bi then we start cleaning of data.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjioqaPIR3_Ng2Or2PJbEtQi1jOojIcPxRiidwxhwzA54nnSirOwXtUTlX9aa1_MT4Ujk12zsnHrZYv-tQyl8n1Oxb6abXHCa0EoBXuv1hyqA0dE_CTvK_rJOKfasshX8RSWdHqxE_l1emOW-yFSKMBsq_dmZdmKBuD4fErJMU9-wXaJJ0UC5Ty8pEfB8Wy/w600-h295-rw/a.jpg)
To do that we click on the arrow beside the remove rows icon from the home ribbon and there we select the option of removing top rows then a dialog box opens where we enter 2 to remove the top 2 rows.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgba4YzPBl9Y9A84lJ0dEzGNuAdsTxeTidrGX-6rybk8HBhWrtouYwiEYlnt974Sp5u_y7DcLvM0Px1Hq4efOClTz2ph3v7CpG-ILMLjsZTYTXjfsidMWS8hSnt6cNaYRnXSAmVa5rb5AqUlpWTwFD9IxuyabuX7tqA99fcDaWXFPTmyRxngWSIT9YO6ZlB/w632-h265-rw/b.jpg)
Now if we look at the bottom rows there are many null and unnecessary values which are not required. So to remove these rows we click on Keep Rows and select Keep Top rows then a dialog box opens and in the dialog box we enter 19 and hit enter.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQBXyyz69_Ws938ujdw8tg4f1RGQF8nXrs2SA71nknEEoMOMGdZZJ1ttWw2qBL_E2JZdnWgrkh8LCnH9QvfZhuH3nQ9CydxLSWQETVOxaLIDLDrEwcayimdPfVW2sJGEv3xsS32Zel6sjhVslpgw41zqoe9pBvByLSckVJPdXBHIPLEPKQdfBMZbOxzHbH/w512-h310-rw/d.jpg)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCIKGpYQDNy2NCc6Z3anaBQGzi-wKNDGB6Q567_sBU_zNMnpNVvqXUoIEnQdTHgyziLmC8HL-knYPBbtK-Wpp7FV4mqbc8mq8-_Cbe-Gcv5HDdtvpo39qNVQrbczEzfbj2t3WEk4pbrb9JAJSS5AOnRhfRM7F0s9aSZPYN-FKflVuhXBJeopQoO8H7bBEH/w517-h328-rw/e.jpg)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEialQwxnDkbMtkZc4xDMUbBPd8Kt7OyBVZn-fKGONBvJFXnP9iobt6JiC_2US-4Tgu6-99QtJSJcVd8iw_OJye1wt_kIwnatt8VzE9ynbRkxdDj6JG8JIP5WvMvH3N6K6r0eV78pqg0EamBABw-SG8ka0Twa6i31vZk12moRm4vWBc2KrXojHsmF2MnDXIT/w530-h272-rw/f.jpg)
Now to achieve c5-c4.
we will merge queries. To do merge queries we go to the home ribbon and select merge queries. then a dialog box opened inside the box first table is expenditure and in the second table, we select the current table which is expenditure current. In join kind, we select left outer join and then press ok.
Now we will expand the expenditure and recipient columns and reorder them. For reordering of the columns, we will select the columns and press the cntrl button to drag the columns to the left or right as per our requirement.
we can see that Expanded Expenditure column values start from 0.
Now if we see the index which starts from 0 is upside down the number 0 is at the very bottom. So we will sort it, to sort it we will click the arrow button near the header of the column and sort it in ascending order.
Now we have to achieve the column of % change exp, to do that we will go to add column's ribbon and there we will click on the custom column. A dialog box opened there we will add the name as % change exp and inside the custom column formula, we will add the formula. The formula is c5-c4 divided by c4 according to the Excel sheet and here it is Expenditures - Expanded Expenditures divided by Expanded Expenditures and to make this value into percentage we multiply it by 100. Now we have the column but our values go for many numbers after decimal. So we have to round up our values, to do that we will follow a similar trick we will right-click on the column and then select round and inside the dialogue box we will enter 2 for decimal numbers.
https://docs.google.com/spreadsheets/d/1YWxA0x9hfQlYwHewXRlvgzVAhhihnTzU/edit?usp=sharing&ouid=108443129400256986779&rtpof=true&sd=true
For a detailed explanation, you can visit this video
Detailed Video
Comments
Post a Comment