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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Viers442
New Member

Creating Weekly Aggregates (4wk, 12wk, 52wk, YTD) and the Year Ago Counterparts

I'm new to PowerBI but am very familiar with data and Excel.

 

For background...I am running a DirectQuery connection to an Amazon Reshift database. Which I do understand brings a host of limitations. My data set is too large for import, so DirectQuery is my option. 

 

I have weekly sales data for the last 4 years by customer in 1 table. Every 4 weeks I get a new set of 4 individual weeks of data appended to the table. I need to report out sales on a 4week, 12week, 52week, and YTD basis. I also need to show the % change vs year ago (YA), so I need to be able to calculate 4week YA, 12week YA, 52week YA, and YTD YA.

 

I've been able to create my current time periods using the following formula (using 4wk as the example)...

 

$_Sales_4wks =

CALCULATE([$_Sales],

DATESINPERIOD(2016_2018_trimmed[period_end_date],

LASTDATE(2016_2018_trimmed[period_end_date]),

-28,

DAY

)

)

 

I have two questions...

 

1. Is this the most efficient way to write my current time period aggregates?

2. How can I create the YA counterpart to each aggregate (in this case 4wk)? 

 

I tried creating the YA time periods using this formula...

 

$_Sales_4wks_YA =

CALCULATE([$_Sales_4wks],

SAMEPERIODLASTYEAR(2016_2018_trimmed[period_end_date])

)

 

However, I am getting numbers that are larger than what I know to be correct. I am thinking that the SAMEPERIODLASTYEAR function is not aligning itself exactly to the correct 4wks last year and that is driving my difference. 

 

Can anyone offer guidance on what seems to be happening with the YA calclation?

 

Thank you!

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@Viers442,

 

You may try using DAX Studio and implement a custom DAX formula for time intelligence function.

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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