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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Aryaja96
Frequent Visitor

Date ranges

Hello, i have a calendar table like this, my date starts from 1/1/21 and ends on 31/12/2022.

Screenshot 2022-06-14 160216.png

what i want to do is create a separate column that groups my date according to the week that they belong in. for example

if i select a particular week range, like 2nd to 3rd week, the date on the horizontal axis shows only the dates belonging to the particular range like( 2nd to 3rd week should show dates from 4/1/2021-17/1/2021. 

Screenshot 2022-06-14 163830.png

like this, it has nothing in it right now but i just wanted to show what i was thinking of doing. 

is there any way to do that?

 

 

 

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

Hi @Aryaja96 ,

 

Please create these.

Table.

 

Table = 
DISTINCT (
    SELECTCOLUMNS (
        CALENDAR ( MIN ( 'Calendar'[Date] ), MAX ( 'Calendar'[Date] ) ),
        "Start", WEEKNUM ( [Date], 2 ),
        "End", WEEKNUM ( [Date], 2 ) + 1
    )
)

 

Calculated column.

 

Column = [Start] & " to " & [End] & " Week"

 

Measure.

 

Measure = 
VAR _weeknum = MAX('Calendar'[Week of Year])
VAR _start = MAX('Table'[Start])
VAR _end = MAX('Table'[End])
VAR _result = IF(_weeknum>=_start&&_weeknum<=_end,1)
RETURN
_result

 

Configure filters.

vcgaomsft_1-1655432996703.png

Attached PBIX file for reference.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @Aryaja96 ,

 

Please create these.

Table.

 

Table = 
DISTINCT (
    SELECTCOLUMNS (
        CALENDAR ( MIN ( 'Calendar'[Date] ), MAX ( 'Calendar'[Date] ) ),
        "Start", WEEKNUM ( [Date], 2 ),
        "End", WEEKNUM ( [Date], 2 ) + 1
    )
)

 

Calculated column.

 

Column = [Start] & " to " & [End] & " Week"

 

Measure.

 

Measure = 
VAR _weeknum = MAX('Calendar'[Week of Year])
VAR _start = MAX('Table'[Start])
VAR _end = MAX('Table'[End])
VAR _result = IF(_weeknum>=_start&&_weeknum<=_end,1)
RETURN
_result

 

Configure filters.

vcgaomsft_1-1655432996703.png

Attached PBIX file for reference.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

hey @v-cgao-msft that totally worked! thank you for the help! 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors