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.
Hi All,
I need Assistence on this
I have Date column, in that i need to present weeks as
May 1 to 7
May 8 to 14
May 15 to 21
May 22 to 28
May 29 to June 4 Like this
Thank you for in Advance.
Hi,
I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.
It is for creating a calendar table like below.
New calendar table =
VAR _t =
ADDCOLUMNS (
CALENDAR ( DATE ( 2023, 1, 1 ), DATE ( 2023, 12, 31 ) ),
"Year-Week",
IF (
MONTH ( [Date] ) = 1
&& WEEKNUM ( [Date], 21 ) > 50,
YEAR ( [Date] ) - 1 & "-"
& WEEKNUM ( [Date], 21 ),
YEAR ( [Date] ) & "-"
& WEEKNUM ( [Date], 21 )
)
)
VAR _weekcolumn =
ADDCOLUMNS (
_t,
"weekcolumn",
IF (
MONTH ( MINX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ) )
= MONTH ( MAXX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ) ),
FORMAT (
MINX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
"mmm-dd"
) & " to "
& FORMAT (
MAXX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
"dd"
),
FORMAT (
MINX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
"mmm-dd"
) & " to "
& FORMAT (
MAXX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
"mmm-dd"
)
)
)
RETURN
_weekcolumn
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.
Hi,
Thank you for your message, if you already have a date column, and if your expected outcome is to create an additinal column in the same table, please check the below picture and the attached pbix file.
Thank you.
WeekColumn CC =
VAR _t =
ADDCOLUMNS (
'Calendar',
"Year-Week",
IF (
MONTH ( [Date] ) = 1
&& WEEKNUM ( [Date], 21 ) > 50,
YEAR ( [Date] ) - 1 & "-"
& WEEKNUM ( [Date], 21 ),
YEAR ( [Date] ) & "-"
& WEEKNUM ( [Date], 21 )
)
)
VAR _weekcolumn =
ADDCOLUMNS (
_t,
"weekcolumn",
IF (
MONTH ( MINX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ) )
= MONTH ( MAXX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ) ),
FORMAT (
MINX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
"mmm-dd"
) & " to "
& FORMAT (
MAXX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
"dd"
),
FORMAT (
MINX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
"mmm-dd"
) & " to "
& FORMAT (
MAXX ( FILTER ( _t, [Year-Week] = EARLIER ( [Year-Week] ) ), [Date] ),
"mmm-dd"
)
)
)
RETURN
SUMMARIZE (
FILTER ( _weekcolumn, 'Calendar'[Date] = EARLIER ( 'Calendar'[Date] ) ),
[weekcolumn]
)
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
97 | |
75 | |
63 | |
53 |
User | Count |
---|---|
139 | |
100 | |
95 | |
85 | |
63 |