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 guys,
I'm trying to group my dates by week and used the Grouping function and it worked ok. But I'd like to group by the week ending date and not by the week starting like it is doing right now. For example when I put the data on a matrix I see the following dates
12/15/2019 , 12/22/2019 - which are my week start dates
but I would like to see 12/14/2019 , 12/21/2019, 12/28/2019 instead which are my week ending dates. Any ideas how to achieve that?
Thank youuu!!
Solved! Go to Solution.
Hi @Anonymous
Try this Column.
Column 2 =
VAR __yearWeek = FORMAT( 'Calendar'[Date], "YYYYWW" )
RETURN
CALCULATE(
MAX( 'Calendar'[Date] ),
ALL( 'Calendar' ),
FORMAT( 'Calendar'[Date], "YYYYWW" ) = __yearWeek
)
hi @Anonymous
You could use this formula to create a calculate column as below:
Result:
and here is sample pbix file, please try it.
Regards,
Lin
Hi @Anonymous
Try this Column.
Column 2 =
VAR __yearWeek = FORMAT( 'Calendar'[Date], "YYYYWW" )
RETURN
CALCULATE(
MAX( 'Calendar'[Date] ),
ALL( 'Calendar' ),
FORMAT( 'Calendar'[Date], "YYYYWW" ) = __yearWeek
)
@Mariusz sorry to go back to this but the calculation seems to have an issue with the year end. For example it groups the week of 12/28 (from 12/22 to 12/28) and then it groups 29,30,31/12 as 31/12 and then 01,02,03,04/01 as another group. Do you have any idea on how to fix this? Thank you!!
Hi @Anonymous
You can add a column in the query editor, like below.
Thanks Mariusz but in this case I would be using a Date table that was created using Dax, therefore it doesn't not show on the Power Query Editor. How can I go about that?
You can create a Date table and there you can have week start and week end dates. and group as per need
Week Start date = DATEADD('Compare Date'[Compare Date],-1*WEEKDAY('Compare Date'[Compare Date])+1,DAY)
Week End date = DATEADD('Compare Date'[Compare Date],7-1*WEEKDAY('Compare Date'[Compare Date]),DAY)
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.
Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601
Thank you @amitchandak but after WEEKDAY is calling another function or measure and doesn't allow me to call the table, do you know why? thanks!
Week End date = DATEADD('Compare Date'[Compare Date],7-1*WEEKDAY('Compare Date'[Compare Date]),DAY)
Hope you have done changes required in formula to suite your table. Can you share formula, relation and error.
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 |
---|---|
97 | |
97 | |
81 | |
77 | |
66 |
User | Count |
---|---|
126 | |
105 | |
103 | |
81 | |
72 |