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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Viktor_
New Member

Calculate previous years data without date, data aggregeted to weeks

Hi All,

 

I would like to ask some help.

I have an aggregated table to weeks with ordered quantity. I would like to calculate the previous years orders
on the same week by the Partner-Product_ID-WEEK level.
I have tried a lot of calculation, but neither works. Tried to get to clear the filter on weeks and after would like to get the WEEK_LY column value in the related row and then filter back the weeks.
The main aim is a measure but also calculated column is fine.
Also have to work correctly on totals in a matrix on all level.

Hope clearly define the problem and there is a solution.

Thank you in advance!

 

Partnerproduct_IDPeriodWEEKWEEK_LYQuantity_orderedQuantity_ordered_LY
Partner 1product 123P1123W4822W48541
Partner 2product 122P1022W4121W41181
Partner 2product 122P1222W5121W511441
Partner 3product 124P0724W3123W311441
Partner 3product 124P0924W3823W381081
Partner 3product 124P1224W5023W501261
Partner 4product 222P0922W3721W371801
Partner 4product 222P0922W3821W38361
Partner 4product 222P1022W4421W44541
Partner 4product 222P1122W4721W47361
Partner 4product 223P0923W3722W37181
Partner 4product 223P1223W4922W49181
Partner 4product 323P1223W5122W51181
Partner 5product 124P0224W0823W08361
Partner 5product 124P0224W0923W09721
Partner 5product 124P0324W1323W13541
6 REPLIES 6
V-yubandi-msft
Community Support
Community Support

Hi @Viktor_ ,

Has your issue been resolved, or do you require any further information? Your feedback is valuable to us. If the solution was effective, please mark it as 'Accepted Solution' to assist other community members experiencing the same issue.

V-yubandi-msft
Community Support
Community Support

Hi @Viktor_ ,

Could you let us know if your issue has been resolved or if you are still experiencing difficulties? Your feedback is valuable to the community and can help others facing similar problems.

 

Thank You.

V-yubandi-msft
Community Support
Community Support

Hi @Viktor_ ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank You.

Viktor_
New Member

@bhanu_gautam Thank you for your quick answer!
I tried and I have only grand total, there is no values for others. And total is not correct.
What could be the error?
Thank you!

Hi @Viktor_ ,

Thanks for sharing your result it helps pinpoint the issue.

Your grand total shows, but row level values are missing because EARLIER() doesn't work well in measures like SUMX(), as it lacks row context.

Use VAR and CALCULATE in your measure to properly maintain row context. This ensures correct calculations at both individual row and total levels in matrix visuals.

 

I hope this helps.  Did I answer your question? Mark my post as a solution.

bhanu_gautam
Super User
Super User

@Viktor_ To ensure that the totals are calculated correctly in a matrix, you might need to use a slightly different approach. Here is an alternative measure that handles totals correctly:

DAX
Quantity_ordered_LY =
SUMX(
'YourTable',
CALCULATE(
SUM('YourTable'[Quantity_ordered]),
FILTER(
'YourTable',
'YourTable'[Partner] = EARLIER('YourTable'[Partner]) &&
'YourTable'[product_ID] = EARLIER('YourTable'[product_ID]) &&
'YourTable'[WEEK] = EARLIER('YourTable'[WEEK_LY])
)
)
)

 

Add the Quantity_ordered_LY measure to your matrix visualization in Power BI. This will show the previous year's orders for the same week at the Partner-Product_ID-WEEK level.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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