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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
CarlsBerg999
Helper V
Helper V

Gantt Chart Date slicer

Hi,

 

I have an issue with creating an effective slicer to a gantt chart. The issue is with the dates, each task has a start and end date. What i want to have on a slicer is "Current Month, Next Month, Next Quarter, Current Year". For example:

 

Next Month should include all tasks that have an end date next month OR has a start date next month. 

Next Quarter  should include all tasks that have an end date next quarter OR has a start date next quarter.

 

How would you perform this? Note that Gantt or slicer visual doesn't accept measures. Therefore i think we need to work with calculated columns.

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @CarlsBerg999 ,

 

I'd suggest you create a flag measure based on the different date period.

 

Please follow these steps:

1. Create a separate table for slicer via Enter data:

Create a table for slicer.PNG

 

2. Create a flag measure:

Flag =
VAR _start =
    MONTH ( MAX ( 'Data'[Start Date] ) )
VAR _end =
    MONTH ( MAX ( 'Data'[End Date] ) )
VAR _today =
    MONTH ( TODAY () )
RETURN
    SWITCH (
        MAX ( 'ForSlicer'[Period Type] ),
        "This Month",
            IF ( _start <= _today && _end >= _today, 1 ),
        "Next Month",
            IF ( _start <= _today + 1 && _end >= _today + 1, 1 ),
        "Next Quarter",
            IF (
                QUARTER ( MAX ( 'Data'[Start Date] ) )
                    <= QUARTER ( TODAY () ) + 1
                    && QUARTER ( MAX ( 'Data'[End Date] ) )
                        >= QUARTER ( TODAY () ) + 1,
                1
            ),
        "This Year",
            IF (
                YEAR ( MAX ( 'Data'[Start Date] ) ) <= YEAR ( TODAY () )
                    && YEAR ( MAX ( 'Data'[End Date] ) ) >= YEAR ( TODAY () ),
                1
            )
    )

 

3. Apply it to filter pane, set as "is 1" , the final output is shown below:

Dynamic date period.gif

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-eqin-msft
Community Support
Community Support

Hi @CarlsBerg999 ,

 

I'd suggest you create a flag measure based on the different date period.

 

Please follow these steps:

1. Create a separate table for slicer via Enter data:

Create a table for slicer.PNG

 

2. Create a flag measure:

Flag =
VAR _start =
    MONTH ( MAX ( 'Data'[Start Date] ) )
VAR _end =
    MONTH ( MAX ( 'Data'[End Date] ) )
VAR _today =
    MONTH ( TODAY () )
RETURN
    SWITCH (
        MAX ( 'ForSlicer'[Period Type] ),
        "This Month",
            IF ( _start <= _today && _end >= _today, 1 ),
        "Next Month",
            IF ( _start <= _today + 1 && _end >= _today + 1, 1 ),
        "Next Quarter",
            IF (
                QUARTER ( MAX ( 'Data'[Start Date] ) )
                    <= QUARTER ( TODAY () ) + 1
                    && QUARTER ( MAX ( 'Data'[End Date] ) )
                        >= QUARTER ( TODAY () ) + 1,
                1
            ),
        "This Year",
            IF (
                YEAR ( MAX ( 'Data'[Start Date] ) ) <= YEAR ( TODAY () )
                    && YEAR ( MAX ( 'Data'[End Date] ) ) >= YEAR ( TODAY () ),
                1
            )
    )

 

3. Apply it to filter pane, set as "is 1" , the final output is shown below:

Dynamic date period.gif

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

VijayP
Super User
Super User

@CarlsBerg999 
after creating dummy table with above mentioned way, you need to create the measure with selectedvalue() which gives control to access the data based on the slicer selection ,

then you can use IF(selectedvalue(nextmonth), what you require,

if(selectedvalue(nextqtr),what you require

is the final measure




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


VijayP
Super User
Super User

@CarlsBerg999 

Create a dumymy TAble with above variables in a column ( as row values)

i.e., "Current Month........"

with Selectedvalue function invoke powerbi to know what you have selected 

and based on that measure you can get final result

 




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Hi, 

Could you elaborate on this? It's not possible to get these all on one column. For example, next quarter includes next month. Therefore, i would need multiple columns. If i have multiple columns, its not possible to create a single slicer for the selected value to pick up upon. I assume that in this idea, i would put selectedvalue as a filter on the visual

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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