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
Anonymous
Not applicable

Using slider to set end date of chart

Hi all,

 

I've been having trouble with a measure I created that is supposed to dynamically calculate hours vs hours available over a moveable time period. This time period is based on a minimum date in the same table the hours lie in. The end date is then set to that minimum date plus the value of a parameter, allowing the user to select how far forward they want to look.

 

Please see my measures below:

 

Latest Load Date = FIRSTDATE(FIN_Hours_Lookahead[Date]) -1

 

Next Week Start = 
[Latest Load Date] + 
    (IF(
        WEEKDAY([Latest Load Date],2) <= 4, 
        (- WEEKDAY([Latest Load Date],2) + 5), 
        (- WEEKDAY([Latest Load Date],2) + 12)
    )
)

 

AvailHrsSlider = 
CALCULATE(
    SUM(FIN_Hours_Lookahead[hoursAvailable]),
    FILTER(FIN_Hours_Lookahead,
        FIN_Hours_Lookahead[Date] >= [Next Week Start]
        && FIN_Hours_Lookahead[Date] <= [AvailBookedHrsEndDate]
    )
)

 

BookedHrsSlider = 
CALCULATE(
    SUM(FIN_Hours_Lookahead[hoursBooked]),
    FILTER(FIN_Hours_Lookahead,
        FIN_Hours_Lookahead[Date] >= [Next Week Start]
        && FIN_Hours_Lookahead[Date] <= [AvailBookedHrsEndDate]
    )
)

 

DiffHrs = [AvailHrsSlider]-[BookedHrsSlider]

 

AvailBookedHrsEndDate = 
[Next Week Start] + (WeeksAhead[WeeksAhead Value]*7)

And finally my parameter:

 

WeeksAhead = GENERATESERIES(0, 13, 1)

WeeksAhead Value = SELECTEDVALUE('WeeksAhead'[WeeksAhead])

 

The final output should look something like below, however, whilst the hours booked/available are working correctly, the parameter input doesn't limit the bars on the chart. If I select 1 in the Weeks Ahead paramter, I should only see 1 bar. If I select 5, I should only see 5.

hours lookahead.png

 

Would anyone have any idea why this isn't working?

Strangely when I change the [Next Week Start] measure to [Report Date] (which is just the TODAY() formula), the parameter input works correctly.

 

Any help would be much appreciate as always!

I know I can count on you guys @Mariusz @MattAllington @v-diye-msft

 

Cheers,

Aaron

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Do you want to show values of weeknum from "Next Week Start" to "AvailBookedHrsEndDate"?

2.png

3.png

Best Regards
Maggie

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.