Forum Discussion

randomUser21's avatar
randomUser21
Resolver I
2 years ago
Solved

How can i set segment default selected value ?

Hello everyone,

How do I set a default selected value on the segment?

example:

today is 10/18/2023 (dd/mm/yyyy), I want the default selected date to be 10/01/2023 to 10/18/2023. and the user can modify this segment value without modifying the filters.

Can anybody help me ?
Thanks
best regards

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi  randomUser21 ,

     

    For the slicer that comes with Power BI, we can not get it. But we can get the three point in the "Visualizations", and we click the "Get more visual":

    Then we find the "Preselected Slicer" and add the visual to our Power Bi Desktop.

     

    Here are the steps you can follow:

    1. First , we need to create a table with one column , and the value is True and False, like this

    2. Second , we can create a measure to define which the date we need to default preselected. If we need to default preselect then we return True else return False.

    Flag =
    var _date=
    SELECTEDVALUE('Table'[Date])
    var _today=TODAY()
    var _min_date=
    DATE(YEAR(_today),MONTH(_today),1)
    return
    IF(
        _date >= _min_date && _date<= _today,TRUE(),FALSE())

    3. Then we can put the 'Table'[Date] in the Fields , [Flag] in the Pre Selection , 'Dirty Table'[Dirty Status] in the Dirty Status, like below screenshot:

    4. Result:

     

     

    Best Regards,

    Liu Yang

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

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  randomUser21 ,

     

    For the slicer that comes with Power BI, we can not get it. But we can get the three point in the "Visualizations", and we click the "Get more visual":

    Then we find the "Preselected Slicer" and add the visual to our Power Bi Desktop.

     

    Here are the steps you can follow:

    1. First , we need to create a table with one column , and the value is True and False, like this

    2. Second , we can create a measure to define which the date we need to default preselected. If we need to default preselect then we return True else return False.

    Flag =
    var _date=
    SELECTEDVALUE('Table'[Date])
    var _today=TODAY()
    var _min_date=
    DATE(YEAR(_today),MONTH(_today),1)
    return
    IF(
        _date >= _min_date && _date<= _today,TRUE(),FALSE())

    3. Then we can put the 'Table'[Date] in the Fields , [Flag] in the Pre Selection , 'Dirty Table'[Dirty Status] in the Dirty Status, like below screenshot:

    4. Result:

     

     

    Best Regards,

    Liu Yang

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

    • randomUser21's avatar
      randomUser21
      Resolver I

      Anonymous  Thank you for your answer ,
      this is not possible on the calendar segment?
      I tried your solution it works well but this form will not suit my users they would have needed a calendar.