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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
kamalmsharma
Helper II
Helper II

To create date table for the week based on date selected from slicer

 I am trying to create two tables in Power BI report based on a date selected from the slicer. The first table needs to have dates for all days of the week belonging to the selected date. The second table needs to have all the dates of the previous week. Please help me to achieve this, 

1 ACCEPTED SOLUTION
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @kamalmsharma,

 

I hope you mean the table visual rather than the calculated table, which doesn't respond to the slicer. 

Please download a demo from the attachment. 

1. Create a slicer table without any relationship to other tables.

2. Create two measures.

thisWeek =
VAR selectedDate =
    SELECTEDVALUE ( 'SlicerTable'[Date] )
RETURN
    IF (
        ISBLANK ( selectedDate ),
        BLANK (),
        IF ( WEEKNUM ( MIN ( 'Table'[Date] ) ) = WEEKNUM ( selectedDate ), 1, BLANK () )
    )
previousWeek =
VAR selectedDate =
    SELECTEDVALUE ( 'SlicerTable'[Date] )
RETURN
    IF (
        ISBLANK ( selectedDate ),
        BLANK (),
        IF (
            WEEKNUM ( MIN ( 'Table'[Date] ) )
                = WEEKNUM ( selectedDate ) - 1,
            1,
            BLANK ()
        )
    )

3. Either adding the measures in the table or putting in the Visual Level Filter.

To_create_date_table_for_the_week_based_on_date_selected_from_slicer

 

 

Best Regards,

Dale

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

View solution in original post

2 REPLIES 2
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @kamalmsharma,

 

I hope you mean the table visual rather than the calculated table, which doesn't respond to the slicer. 

Please download a demo from the attachment. 

1. Create a slicer table without any relationship to other tables.

2. Create two measures.

thisWeek =
VAR selectedDate =
    SELECTEDVALUE ( 'SlicerTable'[Date] )
RETURN
    IF (
        ISBLANK ( selectedDate ),
        BLANK (),
        IF ( WEEKNUM ( MIN ( 'Table'[Date] ) ) = WEEKNUM ( selectedDate ), 1, BLANK () )
    )
previousWeek =
VAR selectedDate =
    SELECTEDVALUE ( 'SlicerTable'[Date] )
RETURN
    IF (
        ISBLANK ( selectedDate ),
        BLANK (),
        IF (
            WEEKNUM ( MIN ( 'Table'[Date] ) )
                = WEEKNUM ( selectedDate ) - 1,
            1,
            BLANK ()
        )
    )

3. Either adding the measures in the table or putting in the Visual Level Filter.

To_create_date_table_for_the_week_based_on_date_selected_from_slicer

 

 

Best Regards,

Dale

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

Hi 

 

Thank you so much for this excellent solution and sample file. It worked perfectly.  

 

Regards,

Kamal

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors