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
gmlhawkins
New Member

Data for this day last year?

I have a csv data source that is just really a log file. Each row contains a date and then the totals from another system in various other columns (Date, Total Hours, Total Students,) etc. The file is written each day in the early morning. I have been successful in showing data just for today but I would like to also show data from this day, last year. I am relatively new to this and cannot figure it out. 

2 REPLIES 2
AlexChen
Employee
Employee

Hi,

 

I assure the table you imported from CSV looks like below.

 

 

1.png

 

You can create a calculated column to get last year sam day’s value.

 

lastYearTotals = var

             lastYear = DATEADD(logInfo[date], -1, year)

         return

             LOOKUPVALUE(logInfo[totals], logInfo[date], lastYear)

 

This is the result:

 

2.png

 

Best Regards

Alex

GilesWalker
Skilled Sharer
Skilled Sharer

@gmlhawkins There are a couple ways this can be done. Firstly you will need to create a date table, see the post below where I spoke about this:

 

http://community.powerbi.com/t5/Desktop/Noob-Date-question/m-p/38881#

 

Once you have this date table you then create a relationship to the CSV file you have through the date column. Then you can use DAX formulas such as SAMEPERIODLASTYEAR

 

Are the CSV files you get always in the same format, i.e. the columns are always the same? If so then you can keep them all in one folder and use the get data / folder option in Power BI desktop and this will join them all together.

 

Thanks,

 

Giles

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.