Forum Discussion

saben02's avatar
saben02
Frequent Visitor
3 years ago

create a period segment between two dates

Hello ! 

I created a segment to choose a period to display my data in a visual table :

My problem is that the "between" style requires me to choose a day, a month and a year, whereas in my calendar table I only have the notion of month and the year, the days being all the first of the month : 

 

 

I have a problem because I want to display my selection in an other visual, and when I choose a day higher than the first of the month for the start date, it displays the next month in my selection : 

 

 

here is the code to display the selection : 

 

How to solve this problem?

 

 

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi saben02 ,

     

    According to your data model, I think your issue should be caused that 03/01/2017 is not in range 03/25/2017 to 05/25/2017 and there is only 03/01/2017 in your data model. So Power BI couldn't find date in March, it will return 04/2017. Here I suggest you to create a calendar table by CALENDAR() or CALENDARAUTO() function which with continuous date.

    Then your measure should look like as below.

    choix seg date P1 onglet cumul =
    IF (
        ISFILTERED ( 'Calendar'[Date] ),
        "From " & FORMAT ( MIN ( 'Calendar'[Date] ), "MM/YYYY" ) & " to "
            & FORMAT ( MAX ( 'Calendar'[Date] ), "MM/YYYY" ),
        "All the period"
    )

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

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

     

    • saben02's avatar
      saben02
      Frequent Visitor

      Hello, thank you so much for your reply.

      This method solves my display problem but still doesn't show the data for the corresponding periods.

       

      Indeed , if the user chooses a date other than the first of the month, I want it to display only the data for that month.

      But here when I choose January 2, 2017 on my slicer, for example, it will take into consideration the data for the following month, i.e. February. ☹️