Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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.
User | Count |
---|---|
98 | |
90 | |
83 | |
70 | |
67 |
User | Count |
---|---|
113 | |
104 | |
101 | |
73 | |
65 |