In sheets, I need to sum each work week beginning on Wednesday and ending on Tuesday with the pay being paid multiple times on any day therein - sumproduct

Sum a payweek that is always Wednesday through Tuesday each week where the payments are made multiple times throughout that week on any day in that week, i.e., payments might be Thursday, Saturday, and Sunday only. Next week might be Wednesday,Friday, and Tuesday. So the day of the week of payments vary as do the number of payments in that week (once, twice, three times, etc).
I need something like weeknum where the day the week the week starts can be chosen (Wednesday). Can add a helper column if needed.
4835259 Mon 3/21 CINCINNATI $8,000
5245716 Tue 3/22 HIGHLAND IL $2,500
5352002 Thu 3/24 LOUISVILLE $4,475
5352016 Fri 3/25 NASHVILLE $3,375
So in this example, I only want $4475 & $3375 summed. Most recent days of week Wednesday through Tuesday (Never including last Tuesday). As you can see, data is not necessarily entered for every day of the week. So just counting back seven days won't work. The most recent week to be totalled might have 4 or 5 entries to sum, or only 1 or 2. Sum each week Wednesday through Tuesday not including last Tuesday.
Below works, but w/o the fixed range. Or count Tuesday but only keep the most recent Tuesday to eliminate last Tuesday.
=SUMPRODUCT(F421:F423, (B421:B423="Wed"
)+(B421:B423="thu")+(B421:B423="fri")+(B421:B423="sat")+(B421:B423="sun")+(B421:B423="mon")+(B421:B423="tue"))

=SUMPRODUCT(--(WEEKNUM(C370:C423+0,13)=C426),F370:F423)

Related

How to show the latest value in card in powerbi

I have the following chart which shows sick leave per person for July and August and on top of that is a card that shows the average of all the months, so in this case is average of July and August which gives 1.55.
Instead of the average, I want the card to show the latest value of the month, so in this case I want the card to show August value which is 0.79 and when September data is loaded, I want the card to show September data instead, unless someone clicks on a different month, then the card should update to show average of what they selected.
For the measure to show the latest months data you could do something like this
Latest Month Average =
VAR latest_month =
MONTH ( CALCULATE ( MAX ( 'Table'[SickDate] ) ) )
RETURN
CALCULATE (
AVERAGEX ( VALUES ( 'Table'[Person] ), COUNT ( 'Table'[SickDate] ) ),
FILTER ( 'Table', MONTH ( 'Table'[SickDate] ) = latest_month )
)
Im not sure what you're data looks like so im making assumptions based on your visual
So im assuming a table like this
Person
SickDate
Jim
Thursday, 1 September 2022
Jane
Thursday, 1 September 2022
John
Saturday, 1 October 2022
Jim
Thursday, 1 September 2022
Jane
Thursday, 1 September 2022
John
Saturday, 1 October 2022
Phil
Sunday, 2 October 2022
So the measure basically gets the latest month in the data
Counts the amount of dates (sick days) by person and takes an average
Note: if you're showing multiple years you would need to get the latest month and year to filter correctly and not just month

Distinct count basis condition for last 3 months

Outlet ID
Outlet Name
Order Date
Product
Qty
Net Value
Mum_1
Prime Traders
12th Oct 2022
RoundBox
3
300
Mum_4
Avon Trading
13th Oct 2022
Slice 100
10
1000
I have date wise transaction data for past 20 months for retail outlets.
Any outlet that has been billed in the last 3 months can be classified as an 'Available Outlet'.
Eg: Available outlets for Sept 2022 are the ones that have been billed at least once across July, August & Sept 2022.
Similarly I need to have ,month wise availability count in a column chart. Can someone please guide as to how can I write a DAX query for the same ?

Week number calculation in Power BI

I am new to Power BI.I have one year filter (Range filter) and one week number filter (Range filter). I want to calculate values such that when i select year 2021 to 2022 and week number 42 to 10 it will first show data for 42th weeks to 52th weeks for year 2021 and for 1st week to 10 th weeks for year 2022.

PowerBI and filtered sum calculation

I should be able to make a report concerning a relationship between sick leaves (days) and man-years. Data is on monthly level, consists of four years and looks like this (there is also own columns for year and business unit):
Month Sick leaves (days) Man-years
January 35 1,5
February 0 1,63
March 87 1,63
April 60 2,4
May 44 2,6
June 0 1,8
July 0 1,4
August 51 1,7
September 22 1,6
October 64 1,9
November 70 2,2
December 55 2
It has to be possible for the user to filter year, month, as well as business unit and get information about sick leave days during the filtered time period (and in selected business unit) compared to the total sum of man-years in the same period (and unit). Calculated from the test data above, the desired result should be 488/22.36 = 21.82
However, I have not managed to do what I want. The main problem is, that calculation takes into account only those months with nonzero sick leave days and ignores man-years of those months with zero days of sick leaves (in example data: February, June, July). I have tried several alternative functions (all, allselected, filter…), but results remain poor. So all information about a better solution will be highly appreciated.
It sounds like this has to do with the way DAX handles blanks (https://www.sqlbi.com/articles/blank-handling-in-dax/). Your context is probably filtering out the rows with blank values for "Sick-days". How to resolve this depends on how your data are structured, but you could try using variables to change your filter context or use "IF ( ISBLANK ( ... ) )" to make sure you're counting the blank rows.

Week number calculation in rails

This is my first question on Stack.
I am working on a booking site that relies heavily on searching and finding full weeks of accommodation. Most user searches will be on weeknumber of the year, eg. week 27 for the first week of july.
It is important that the user does not need to fill in year when searching for accommodation, and so the only thing we will get from the user is the weeknumber.
How can I get the year from the week given by the user considering that it always has to be the next upcoming occurrence of that week number?
(There is a gotcha in this. I could get the upcoming week 27 by doing something like this:
def week
week = 27
Date.commercial(Date.current.year + 1, week, 1) # gives the first day of the week
end
But that would only be right until the 1 of January, after that it would be looking for week 27 of 2015.)
You could compare the current calendar week with Date.current.cweek (Reference) with your number.
require 'active_support/core_ext' # Already included in Rails
def calendar_week(week)
now = Date.current
year = now.cweek < week ? now.year : now.year + 1
Date.commercial(year, week, 1)
end
p calendar_week(49)
# => Mon, 02 Dec 2013
p calendar_week(1)
# => Mon, 30 Dec 2013 # don't know if that's the way calendar weeks are counted
p calendar_week(27)
# => Mon, 30 Jun 2014