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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kiril
Frequent Visitor

Calculating prior month values

We have a monthly data export which creates plain csv files of a Project table. The monthly data exports contain the whole table. Thus, the base data we have is:

 

projects_2022_01.csv

projects_2022_02.csv

projects_2022_03.csv

...

 

A project has a state that can be scheduled, active, finished, overdue. I want to create a table which shows the current state of the projects and a comparison with prior month grouped by state:

 

 Current (data from projects_2022_03.csv)Prior Month (data from projects_2022_02.csv)
Scheduled56
Active21
Overdue10
Finished109

 

 

 

I can easily load the data into a single table in Power BI, but I wonder if that's the best data model?

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @kiril ;

You could combine this excel files in power query .

https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-combine-binaries

1.Put all your workbooks in a folder, then click Get Data->Folder-> Edit.

2.After step 1, click context column then click Combine Files like below:

vyalanwumsft_0-1650424161389.png

3.Choose which type of sheet you want to combine to a single table, here I choose Sheet 1, it means sheet1 in all the workbooks will be combined to a single table:

4.The result is like below:

vyalanwumsft_1-1650424199115.png

5.In desktop, we could use matrix.

vyalanwumsft_2-1650424245778.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-yalanwu-msft
Community Support
Community Support

Hi, @kiril ;

You could combine this excel files in power query .

https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-combine-binaries

1.Put all your workbooks in a folder, then click Get Data->Folder-> Edit.

2.After step 1, click context column then click Combine Files like below:

vyalanwumsft_0-1650424161389.png

3.Choose which type of sheet you want to combine to a single table, here I choose Sheet 1, it means sheet1 in all the workbooks will be combined to a single table:

4.The result is like below:

vyalanwumsft_1-1650424199115.png

5.In desktop, we could use matrix.

vyalanwumsft_2-1650424245778.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBI file and the CSV files.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

There is nothing really amazing in the pbi file, except for the loaded csv files. The files look like the following listing.

 

projects_2022_01.csv:

Project nameExport dateState
Project A2022-01-31Active
Project B2022-01-31Overdue

 

projects_2022_02.csv:

Project nameExport dateState
Project A2022-02-28Active
Project B2022-02-28Finished
Project C2022-02-28Scheduled

 

After importing those files to Power BI, there is one table in Power BI:

Project nameExport dateState
Project A2022-01-31Active
Project B2022-01-31Overdue
Project A2022-02-28Active
Project B2022-02-28Finished
Project C2022-02-28Scheduled

 

From this combined table I am trying to calculate current month values and prior month values:

 Current (2022-02-28)Prior month (2022-01-31)
Scheduled1 
Active11
Overdue 1
Finished1 

 

 

Hi,

Create a Calendar Table and write calculated column formulas to extract Year, Month name and Month number.  Sort the Month name by the Month number.  Create a relationship (Many to One and Single) from the Export Date column to the Date column of the Calendar Table.  To your matrix visual, drag Year and Month name from the Calendar Table to the Column well and State to the row well.  Write these measures:

Count = countrows(Data)

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
davehus
Memorable Member
Memorable Member

Hi @kiril, Do you have a date column in the csv file and a date table in your model?

kiril
Frequent Visitor

Yes, there is a date column present

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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