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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
saben02
Frequent Visitor

create a period segment between two dates

Hello ! 

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

saben02_1-1684930396695.png

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 : 

 

saben02_2-1684930428287.png

 

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 : 

 

saben02_3-1684930460983.png

 

here is the code to display the selection : 

 

saben02_4-1684930611309.png

How to solve this problem?

 

 

2 REPLIES 2
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.

veqinmsft_0-1685085535135.png

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.

veqinmsft_1-1685085556391.png

 

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.

 

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. ☹️ 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.