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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
samHil
Frequent Visitor

chart to show sum of previous weeks

Hi,

I want to create a pie chart with NetSales based on Category of products. The slicer has year and week number. When I select week 12. i need the pie chart to show sum of net sales for the week 12,11,10 and 9. That is selected week plus previous 3 weeks.  I have created week Rank column but I am not sure how to add the previous weeks with he current week.

Any Help appreciated

 

Thank you

Sam

2 REPLIES 2
VahidDM
Super User
Super User

Hi @samHil 

 

Do you have a date column in your table? Can you share a sample of your data in a table format here?

BTW, If you have a date column, try to create a measure like this:

add a week No. column to your table and name it WeekNo

then, find the selected week No.:

Var _MaxWeek = WEEKNUM( SELECTEDVALUE([YourDateColumn]))

Var _MinWeek = _MaxWeek-4
then use these two variables to set a filter in your calculation:

filter(Table,WeekNo<=_MaxWeek&&WeekNo>=_MinWeek)

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your KudosโœŒ๏ธ!!

 

samHil
Frequent Visitor

Hi @VahidDM ,

Thank you for the reply. It did not work like this "filter(Table,WeekNo<=_MaxWeek&&WeekNo>=_MinWeek)" . So i created a variables for each week , like selected week -1,selected week -2 etc. Then I used

calculate(sum(Sales[NETSales],TableName[ColumnName]in{_currentWeek,_CurrentWeek1,_CurrentWeek2,_CurrentWeek3,_currentWeek4})

and it worked. I am not sure why filter(Table,WeekNo<=_MaxWeek&&WeekNo>=_MinWeek) did not work

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric 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.

Users online (25)