AWS Quicksight: Display week as a number, grouped by month and not year - amazon-web-services

I need to display Week as number in AWS QuickSight.I understand, we can do this to get the week numbers: In the field wells, click the format option for the date field and on the left side-panel, enter 'w' in the Custom format field.
The issue is this gives the week number in the year. How do I get week number per month?

You can use calculated fields to calculate it.
It depends how you define "week of month". In a simple case, if you define first 7 days of a month as "week 1", the second 7 days as "week 2", etc, use this formula:
dateDiff(truncDate('MM', mydate), mydate, 'WK') + 1
I do a date-diff (in weeks) between first day of month (truncDate) to input-ed date.
Result:

Related

How to get Last Week, Last One Month, Last Six Month, Last Year sales based on Weekending Dates in Power BI

How to get sales of Last Week, Last One Month, Last Six Month, Last Year sales based on selected weekending dates from slicer filter. By using DATESINPERIOD function I'm getting results for last week but when I'm using same function for last 1 Month, 3 Months, 6 Months & 1 Year it is giving me blank values. How to get values for this particular months.
This is how I'm doing my calculation. 
enter image description here
It is giving me results for last week but not for previous months which I wanted.
Note: In my slicer I'm using WeekEnding Dates which look like these 22/01/2023, 15/01/2023, 08/01/20223.
Any help would be greatly appreciated. Thank you.

How to Get Custom Week Desc in DAX

Basis on below data I want to add a calculated column with Week Description
I've done it in excel by typing it manually.
Also my week is starting from Thursday and ends on Wednesday hence I've Used this function to get the weekday WEEKDAY('Calendar'[date],14)
Requesting you to help me with a dax code which can be used to create a new calculated column with week information as shown below in third column.
The logic would be : If the date is current week then the value will be "This Week" else if the
date is in last week then "This Week -1" else if the date is in last to last week then "This Week - 2" and so on.
The weekday can be calculated as following:
Weekday = WEEKDAY([Date] + 3)
We do a shift of 3 days to make Thursday the start of the week
Next, we get the WeekDesc in two steps, frist we calculate the difference between now and the date in weeks and as second step we use an if statement to create the correct sting (and logic).
WeerDesc =
var weeksPast = DATEDIFF(now(), [Date] + 3,WEEK)
return if ( weeksPast = 0, "This Week", "This Week" & weeksPast)
As you can see you can use variables in your DAX, I would recommend using them to keep the overview.
Enjoy
We can do this also in this way (as a measure if you need only label to display on rows):
DayOfWeek = WEEKDAY(SELECTEDVALUE('CAL'[Date]),14)
DiffToToday = DATEDIFF(SELECTEDVALUE('CAL'[Date]),TODAY(),DAY)
Label = CONCATENATE("This Week", (DIVIDE( CAL[DiffToToday] + CAL[DayOfWeek],7) -1) *-1 )
Of course, we can do all steps in one measure.

Power Bi DAX: Divide Value and set it for each week

I have a target value of 20 for January but it is 20 for the month, i need to show this over each week. I have to divide the target by 4 if there are 4 weeks in a month and by 5 if there are 5 weeks in a month. It is as simple as that, i am using a line and clustered column chart to display my data, i need the target spread out into each week of the month. I also need another field to do this but im sure i can replicate your formula and make it applicable.
I have added a WeeksinMonth column that counts how many weeks are in a particular month e.g January has 5 weeks and February has 4 weeks. I need an IF statement that will divide the target and value by how many weeks in a month. e.g if month has 5 weeks then divide target and value by 5, if month has 4 weeks divide target and value by 4.
I have a calendar table with week values which i can used to put the divided target into and also the desired output i made in excel (See attached).
How will i go about this?
Desired Output
Calendar Table
enter code hereYou can create an extra column in your calendar table:
WeekMax =
var stOfMonth = Weeks[Start of Week].[Month]
var stOfYear = Weeks[Start of Week].[year]
return CALCULATE(max(Weeks[Weekinmonth]);FILTER(Weeks;Weeks[Start of Week].[Month] = stOfMonth && Weeks[Start of Week].[Year] = stOfYear))
Make sure you have a relation in your model between calendar and target date. Now you can use this number for that week/date to divide by.
You can now add an extra column in your target table:
WeeklyTarget = Targets[Target]/Related(Calendar[WeekMax])

How to calculate last 4 any weekdays sales in power bi

I want to calculate last 4 any weekdays total sales.Based on filter max date.
Example: I have 2 filter
1. Date range(From -To)
2. Week Day(Like Mon,Tue Etc.)
I need total sales for last 4 Monday or Tuesday (as per above filter ).And Last 4 weekdays will be calculated based on To-date in filter.
Like To-date is 31-Dec'18 then last 4 Tuesday will be 4,11,18,25 Dec.
Thanks in advance for the help.
Nitika, the best way to do that is creating another table to put a 'Dimension' with dates, int that you can put, weekday, day, holiday, year, month...
Something like that:
Do You Need a Date Dimension?
Why use a Date Dimension Table in a Data Warehouse
Doing that you can reference your atual date with this table, and get just the weekday that you are looking for

Power BI - filter data to current week (week number)

I have a power bi report with a line chart that has a field called 'EventDate'
I need to add a filter on to this report to say 'only get me the days where the EventDate matches this week number'
I don't want to display the last 7 days as a relative filter.
I need to do it by this week.
Can anyone help
You can use the week in the relative date filtering and it returns the dates associated with the current week number rather than the last 7 days.