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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Dain
Frequent Visitor

Dynamically find out first working day of months selected in the slicer

Can someone please help

 

 

I have a date slicer with start and end dates.I want to find the first working day of month for each months tat comes in that slicer start n end dates.For each first working day,i want to execute a specific logic.How can i do it dynamically.

 

If my slicer is

 

4/4/2018   to    6/6/2018

 

I want to find out the first working day of May and June. and for these two first working days i wnat execute a specifc logic.

If my slicer is

1/4/2018    to     6/6/2018

then first working day of April,May and June. and for these 3 first working days i want to execute a specific log.

 

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

HI @Dain,

 

If you mean use slicer to get dynamic calculate table, it is impossible.

 

You can try to use two calendar to dynamic filter first work day.(tables not contains relationship)

Steps:

1. Use calendar to create slicer, calendar2 to create table visual.

2. Write a measure to check current row contents if it suitable requirement.

First Working Day =
VAR _current =
    SELECTEDVALUE ( 'CALENDAR2'[Date] )
VAR _firstWeekDay =
    MINX (
        FILTER (
            ADDCOLUMNS (
                CALENDAR (
                    DATE ( YEAR ( _current ), MONTH ( _current ), 1 ),
                    DATE ( YEAR ( _current ), MONTH ( _current ) + 1, 1 )
                        - 1
                ),
                "Day of Week", WEEKDAY ( [Date], 1 )
            ),
            [Day of Week] <> 1
                && [Day of Week] <> 7
        ),
        [Date]
    )
RETURN
    IF (
        _current IN ALLSELECTED ( 'CALENDAR'[Date] ),
        IF ( _current = _firstWeekDay, 1, 0 ),
        0
    )

8.gif

 

BTW, if you only want to export suitable date string based on one calendar, you can refer to below formula.

Suitable Working Day =
VAR temp =
    FILTER (
        ADDCOLUMNS (
            ALLSELECTED ( 'CALENDAR'[Date] ),
            "Year Month", FORMAT ( [Date], "mm/yyyy" )
        ),
        WEEKDAY ( 'CALENDAR'[Date], 1 ) <> 1
            && WEEKDAY ( 'CALENDAR'[Date], 1 ) <> 7
    )
RETURN
    CONCATENATEX (
        SUMMARIZE (
            temp,
            [Year Month],
            "FirstDate", MINX ( FILTER ( temp, [Year Month] = EARLIER ( [Year Month] ) ), [Date] )
        ),
        [FirstDate],
        ","
    )

9.gif

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

HI @Dain,

 

If you mean use slicer to get dynamic calculate table, it is impossible.

 

You can try to use two calendar to dynamic filter first work day.(tables not contains relationship)

Steps:

1. Use calendar to create slicer, calendar2 to create table visual.

2. Write a measure to check current row contents if it suitable requirement.

First Working Day =
VAR _current =
    SELECTEDVALUE ( 'CALENDAR2'[Date] )
VAR _firstWeekDay =
    MINX (
        FILTER (
            ADDCOLUMNS (
                CALENDAR (
                    DATE ( YEAR ( _current ), MONTH ( _current ), 1 ),
                    DATE ( YEAR ( _current ), MONTH ( _current ) + 1, 1 )
                        - 1
                ),
                "Day of Week", WEEKDAY ( [Date], 1 )
            ),
            [Day of Week] <> 1
                && [Day of Week] <> 7
        ),
        [Date]
    )
RETURN
    IF (
        _current IN ALLSELECTED ( 'CALENDAR'[Date] ),
        IF ( _current = _firstWeekDay, 1, 0 ),
        0
    )

8.gif

 

BTW, if you only want to export suitable date string based on one calendar, you can refer to below formula.

Suitable Working Day =
VAR temp =
    FILTER (
        ADDCOLUMNS (
            ALLSELECTED ( 'CALENDAR'[Date] ),
            "Year Month", FORMAT ( [Date], "mm/yyyy" )
        ),
        WEEKDAY ( 'CALENDAR'[Date], 1 ) <> 1
            && WEEKDAY ( 'CALENDAR'[Date], 1 ) <> 7
    )
RETURN
    CONCATENATEX (
        SUMMARIZE (
            temp,
            [Year Month],
            "FirstDate", MINX ( FILTER ( temp, [Year Month] = EARLIER ( [Year Month] ) ), [Date] )
        ),
        [FirstDate],
        ","
    )

9.gif

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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