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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
dgolovanova
Frequent Visitor

MIN value of a slicer based on a date in MM.YYYY format

Good afternoon,

Please help with advice.

There is a field in the DATE format, contains only the month and year (2.2021, 8.2023, etc.).

The client want to use a slicer in the "between" style (they don't like the extra Timeline slicer).

Power BI automatically displays dates in the format dd.mm.yyyy, which means that the table value of 8.2023 corresponds to the value of 1.8.2023.

I use the MIN and MAX functions to determine the minimum and maximum value of the slicer.

I need that if I select a date other than the first day of the month, the selected month will be returned to me, not the next one.

For example, for 5.12.2021, I need to get the value 1.12.2021 instead of 1.1.2022.

Is it possible?

Thank you in advance.

 

dgolovanova_0-1711359024313.jpeg

 

 

dgolovanova_1-1711359024316.jpeg

 

2 ACCEPTED SOLUTIONS

Hi,

In my opinion, if you want to use continuous date in the slicer, but if your fact table (sales table) date column is not continuous, please try using calenar dimension table, something like below.

Calendar = 
VAR _startdate =
    EOMONTH ( MIN ( Sales[Date] ), -1 ) + 1
VAR _enddate =
    EOMONTH ( MAX ( Sales[Date] ), 0 )
RETURN
    CALENDAR ( _startdate, _enddate )

Jihwan_Kim_1-1711686129778.png

 

 

Jihwan_Kim_0-1711686119715.png

 

Min date = 
VAR _selectedmonth =
    MONTH ( MIN ( 'Calendar'[Date] ) )
VAR _selectedyear =
    YEAR ( MIN ( 'Calendar'[Date] ) )
RETURN
    MINX (
        FILTER (
            Sales,
            YEAR ( Sales[Date] ) = _selectedyear
                && MONTH ( Sales[Date] ) = _selectedmonth
        ),
        Sales[Date]
    )

 

Max date = 
VAR _selectedmonth =
    MONTH ( MAX ( 'Calendar'[Date] ) )
VAR _selectedyear =
    YEAR ( MAX ( 'Calendar'[Date] ) )
RETURN
    MAXX(
        FILTER (
            Sales,
            YEAR ( Sales[Date] ) = _selectedyear
                && MONTH ( Sales[Date] ) = _selectedmonth
        ),
        Sales[Date]
    )

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

Good afternoon,
sorry for the late reply.

Everything works.

Thank you very much for help.
Regards

View solution in original post

6 REPLIES 6
dgolovanova
Frequent Visitor

Hello Jihwan,

Thanks for the reply, but this is not exactly what I need.
The problem is that my date field does not contain the day, only the month and year.
If I select the "Vertical List" slider type, the date is displayed the same way as in the table, i.e. in mm.yyyy format.

dgolovanova_0-1711444855371.png

But if you select the "Between" slider type, the date is displayed in the format dd.mm.yyyy.
And if you select a start date greater than the first day of the month, then the minimum value of the slicer already returns the next month, not the current month.
In the following example "Max date" is ok, but "Min date" should be 12.2021 instead of 01.2022.

dgolovanova_1-1711444884790.png

Can't attach the file 😞
Thanks again.
Regards

Hi,

Please provide your sample pbix file, and then I can try to look into it.

Please try using onedrive link or dropbox link to share the link of the sample file.

Thank you.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi,

In my opinion, if you want to use continuous date in the slicer, but if your fact table (sales table) date column is not continuous, please try using calenar dimension table, something like below.

Calendar = 
VAR _startdate =
    EOMONTH ( MIN ( Sales[Date] ), -1 ) + 1
VAR _enddate =
    EOMONTH ( MAX ( Sales[Date] ), 0 )
RETURN
    CALENDAR ( _startdate, _enddate )

Jihwan_Kim_1-1711686129778.png

 

 

Jihwan_Kim_0-1711686119715.png

 

Min date = 
VAR _selectedmonth =
    MONTH ( MIN ( 'Calendar'[Date] ) )
VAR _selectedyear =
    YEAR ( MIN ( 'Calendar'[Date] ) )
RETURN
    MINX (
        FILTER (
            Sales,
            YEAR ( Sales[Date] ) = _selectedyear
                && MONTH ( Sales[Date] ) = _selectedmonth
        ),
        Sales[Date]
    )

 

Max date = 
VAR _selectedmonth =
    MONTH ( MAX ( 'Calendar'[Date] ) )
VAR _selectedyear =
    YEAR ( MAX ( 'Calendar'[Date] ) )
RETURN
    MAXX(
        FILTER (
            Sales,
            YEAR ( Sales[Date] ) = _selectedyear
                && MONTH ( Sales[Date] ) = _selectedmonth
        ),
        Sales[Date]
    )

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Good afternoon,
sorry for the late reply.

Everything works.

Thank you very much for help.
Regards

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file whether it suits your requirement.

 

Jihwan_Kim_0-1711391912959.png

 

STARTOFMONTH function (DAX) - DAX | Microsoft Learn

 

Min Date start of month: = 
CALCULATETABLE (
    STARTOFMONTH ( 'Calendar'[Date] ),
    'Calendar'[Date] = MIN ( 'Calendar'[Date] )
)

 

Max Date start of month: = 
CALCULATETABLE (
    STARTOFMONTH ( 'Calendar'[Date] ),
    'Calendar'[Date] = MAX ( 'Calendar'[Date] )
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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