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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
AleMotta84
Frequent Visitor

Calculate weekly usage of a printer

Hi all,

 

Every week I receive an email from the printer with an attached csv file which contains the print reports divided for each user. I save this file in a sharepoint folder which is where power query takes the data from.

 

The problem is that the report contains the totals from the first day of use of the printer because, unfortunately, I have no way to reset the printer data after each export.

 

I need the weekly usage of the printer. Is there a way in power query to load only the difference between the last file and previous?

 

Thank you

 

AleMotta84_1-1677508926965.png

 

 

1 ACCEPTED SOLUTION

 

Ah, cool. I should have looked more carefully at your screenshot.

 

-1- Sort your data by [Data e ora] ascending.

-2- Add an index column starting from zero and call it [Index0]: Add Column tab > Index Column (dropdown) > 'From 0'

-3- Add an index column starting from one and call it [Index1].

-4- Go to the Home tab > Merge Queries. Select the same query as the second table to merge (you're going to merge the table to itself).

-5- Left Outer merge on Table1[Index0] = Table2[Index1]

-6- Expand [Data e ora] and [Stampa totale] from the nested merge column.

 

You now have the previous report date and the previous report meter read on each weekly row, so you can now get the meter change value and the number of days over which this change occurred.

 

There's a few other tidying bits you'll want to do with column names (Start Date/End Date, Start Read/End Read etc.) but the basic principle of what you need to do is here.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
BA_Pete
Super User
Super User

Hi @AleMotta84 ,

 

If you're keeping each file in a SharePoint folder then the best thing to do would be to connect to that folder using the SharePoint Folder connector in Power Query.

Once you select the SP folder with all your files in, you can choose to 'Combine & Transform Data' to append all those files together into one:

https://support.microsoft.com/en-us/office/import-data-from-a-folder-with-multiple-files-power-query... 

 

Once you have them all in a single table, you can then use either index + self-merge or something more technical to get the previous/next value on each row.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Hi @BA_Pete,

Thanks for the quick reply!

 


@BA_Pete wrote:

Hi @AleMotta84 ,

 

If you're keeping each file in a SharePoint folder then the best thing to do would be to connect to that folder using the SharePoint Folder connector in Power Query.

Once you select the SP folder with all your files in, you can choose to 'Combine & Transform Data' to append all those files together into one:


I already use this connector and I have all data in a single table. 

Sorry, my mistake, I had not specified it.

 


Once you have them all in a single table, you can then use either index + self-merge or something more technical to get the previous/next value on each row.


I need help on this part! 🙂

 

Thanks

Ale

 

 

Ah, cool. I should have looked more carefully at your screenshot.

 

-1- Sort your data by [Data e ora] ascending.

-2- Add an index column starting from zero and call it [Index0]: Add Column tab > Index Column (dropdown) > 'From 0'

-3- Add an index column starting from one and call it [Index1].

-4- Go to the Home tab > Merge Queries. Select the same query as the second table to merge (you're going to merge the table to itself).

-5- Left Outer merge on Table1[Index0] = Table2[Index1]

-6- Expand [Data e ora] and [Stampa totale] from the nested merge column.

 

You now have the previous report date and the previous report meter read on each weekly row, so you can now get the meter change value and the number of days over which this change occurred.

 

There's a few other tidying bits you'll want to do with column names (Start Date/End Date, Start Read/End Read etc.) but the basic principle of what you need to do is here.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




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.