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
BBConsultancy
Helper I
Helper I

Dynamic column chart 10 weeks

Hi,

 

In my Power BI report I want to put a column chart that show the [Sales] of the selected week and 10 weeks prior. I want to select the week using a slicer. I tried multiple things:

 

1. Measure =

VAR _ChosenWeek = SELECTEDVALUE('Reporting Date'[WeekNr])
VAR _ChosenYear = SELECTEDVALUE('Reporting Date'[Year])
VAR _PriorWeek = _ChosenWeek -1
VAR _MinWeek = _PriorWeek - 10
VAR _MaxWeek = _PriorWeek + 1

RETURN
CALCULATE(
    [Sales],
    FILTER(
       'Reporting Date',
       'Reporting Date'[WeekNr] >= _MinWeek &&
       'Reporting Date'[WeekNr] <= _MaxWeek &&
       'Reporting Date'[Year] = _ChosenYear 
    )
)
 
This measure results in the slicer still being dominant and the chart only showing the selected week.

2. 
Measure =
VAR _ChosenWeek = SELECTEDVALUE('Reporting Date'[WeekNr])
VAR _ChosenYear = SELECTEDVALUE('Reporting Date'[Year])
VAR _PriorWeek = _ChosenWeek -1
VAR _MinWeek = _PriorWeek - 10
VAR _MaxWeek = _PriorWeek + 1

RETURN
CALCULATE(
    [Sales],
    FILTER(
       ALL('Reporting Date'),
       'Reporting Date'[WeekNr] >= _MinWeek &&
       'Reporting Date'[WeekNr] <= _MaxWeek &&
       'Reporting Date'[Year] = _ChosenYear 
    )
)

This results in the correct value, but it is all put on the select week. So you'll see one column with the value of all the weeks.

You'll be my hero if you can help me! 🙂
1 ACCEPTED SOLUTION
BBConsultancy
Helper I
Helper I

Thanks! It definitely pointed me in the right direction. The DATESINPERIOD function doesn't accept weeks unfortunately, but I replaced that part with:

VAR _MinWeek = _ChosenWeek- 10
VAR _MaxWeek = _ChosenWeek+ 1
VAR _DateRange =
FILTER(
    ALL('Previous Reporting Date'),
    'Previous Reporting Date'[WeekNr] >= _MinWeek &&
    'Previous Reporting Date'[WeekNr] <= _MaxWeek &&
    'Previous Reporting Date'[Year] = _ChosenWeek
)

View solution in original post

2 REPLIES 2
BBConsultancy
Helper I
Helper I

Thanks! It definitely pointed me in the right direction. The DATESINPERIOD function doesn't accept weeks unfortunately, but I replaced that part with:

VAR _MinWeek = _ChosenWeek- 10
VAR _MaxWeek = _ChosenWeek+ 1
VAR _DateRange =
FILTER(
    ALL('Previous Reporting Date'),
    'Previous Reporting Date'[WeekNr] >= _MinWeek &&
    'Previous Reporting Date'[WeekNr] <= _MaxWeek &&
    'Previous Reporting Date'[Year] = _ChosenWeek
)
johnt75
Super User
Super User

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.