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

PowerBI Embedded - Slicers API - set time slicer

I have a web page with an embedded report. On the report there's a time slicer:

slicer.PNG

I don't want to use the slicer directly, so I added a dropdown with the same values.

Here's how I update the slicer with the values from the dropdown:

function setSlicer(slicer, times) {
        slicer.getSlicerState()
            .then(state => {
                for (var i = 0; i < state.filters.length; i++) {
                    let filter = state.filters[i];
                    if (filter.target.column === "TimeOnly") {
                        filter.values = [];
                        for (var j = 0; j < times.length; j++)
                            filter.values.push(times[j]);
                        break;
                    }
                }
                slicer.setSlicerState(state);
            });
    }

But the values are not getting selected. Instead, they are just added to the end of the slicer creating duplicates.

The report does not look right too. It looks as if all of the time values were selected.

 

If I use the slicer directly and try to get its state, I see this in its filters values:

values: ["1899-12-29T21:57:56.000Z"]

This corresponds to the selected values of 00:00:00.

I tried to convert the values from my dropdown into this format with no luck - the report becomes empty.

 

How do I set the time slicer correctly?

0 REPLIES 0

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.