Tableau Subtotal aggregation trouble - aggregation

Having trouble with my view.
I have 3 columns:
A - total hours worked
B - Total Available Hours
C - Productivity (A/B in a calculated field)
When i click view Grand Totals, the Hours in A and B perfectly align. But the Productivity column, after adjusting measure value to AVG, always shows the average of the fractions in that column, not Total Hours / Total Available Hours in the Grand Total Row. Because of this my %s are slightly off.
I tried looking into LOD as a result but couldn't figure out how to set it up correctly. Hoping to reach out to this community to see if someone can help, since I didnt see a similar post. Thanks in advance!

Related

Number of days for delivery and number of orders delivered in two separate columns. Is there a way to get summary statistics about orders?

I've had a bit of trouble explaining this so please bear with me. I'm also very new to using excel so if there's a simple fix, I apologize in advance!
I have two columns, one listing number of days starting from 0 and increasing consecutively. The other column has the number of orders delivered. The two correspond to each other. For example, I've typed out how it would look below. It would mean that there were 100 orders delivered in 1 day, 150 orders delivered in 2 days, 800 orders delivered in 3 days, etc.
Is there a way to get summary statistics (mean, median, mode, upper and lower quartiles) for the number of days it took for the average order to get delivered? The only way I can think of solving this is to manually punch in "1" 100 times, "2" 150 times, etc. into a new column and take median, mean, and upper & lower quartile from that, but that seems extremely inefficient. Would I use a pivot table for this? Thank you in advance!
I tried using the data analysis add-on and doing summary statistics that way, but it didn't work. It just gave me the mean, median, mode, and quartiles of each individual column. It would have given me 3 for median number of days for delivery and 300 for median number of orders.
Method 1
The mean is just
=SUMPRODUCT(A2:A6,B2:B6)/SUM(B2:B6)
Mode is the value with highest frequency
=INDEX(A2:A6,MATCH(MAX(B2:B6),B2:B6,0))
The quartiles and median (or any other quantile by varying the value of p) from first principles following this reference
=LET(p,0.25,
values,A2:A6,
freq,B2:B6,
N,SUM(freq),
h,(N+1)*p,
floorh,FLOOR(h,1),
ceilh,CEILING(h,1),
frac,h-floorh,
cusum,SCAN(0,SEQUENCE(ROWS(values)),LAMBDA(a,c,IF(c=1,0,a+INDEX(freq,c-1)))),
xlower,XLOOKUP(floorh-1,cusum,values,,-1),
xupper,XLOOKUP(ceilh-1,cusum,values,,-1),
xlower+(xupper-xlower)*frac)
Method 2
If you don't like doing it this way, you can always expand the data like this:
=AVERAGE(XLOOKUP(SEQUENCE(SUM(B2:B6),1,0),SCAN(0,SEQUENCE(ROWS(A2:A6)),LAMBDA(a,c,IF(c=1,0,INDEX(B2:B6,c-1)+a))),A2:A6,,-1))
=MODE(XLOOKUP(SEQUENCE(SUM(B2:B6),1,0),SCAN(0,SEQUENCE(ROWS(A2:A6)),LAMBDA(a,c,IF(c=1,0,INDEX(B2:B6,c-1)+a))),A2:A6,,-1))
=QUARTILE.EXC(XLOOKUP(SEQUENCE(SUM(B2:B6),1,0),SCAN(0,SEQUENCE(ROWS(A2:A6)),LAMBDA(a,c,IF(c=1,0,INDEX(B2:B6,c-1)+a))),A2:A6,,-1),1)
=MEDIAN(XLOOKUP(SEQUENCE(SUM(B2:B6),1,0),SCAN(0,SEQUENCE(ROWS(A2:A6)),LAMBDA(a,c,IF(c=1,0,INDEX(B2:B6,c-1)+a))),A2:A6,,-1))
and
=QUARTILE.EXC(XLOOKUP(SEQUENCE(SUM(B2:B6),1,0),SCAN(0,SEQUENCE(ROWS(A2:A6)),LAMBDA(a,c,IF(c=1,0,INDEX(B2:B6,c-1)+a))),A2:A6,,-1),3)

How to calculate the difference between the total of a column and a value in the column of a measure in Power BI?

I have a column in my matrix table that is a measure called Avg Clinic Visit per Session. I applied the totals to the columns in the matrix. I want to be able to subtract a row in the column from the total. For instance, I want to be able to subtract Charles Prague Avg Clinic Visit per Session of 8 from the column total of 9 to get the difference of 1.
I have tried everything I know, but I can't figure it out, and I have been searching for days to find an answer. I do hope that someone on this site will have a simple answer to my problem.
Thank you in advance.
My Matrix

How to show average productivity

I am trying to figure out how I can get an average of the staff's productivity.
An example of the columns in use is below. I have this as a Data Model as it links to other tables.
I want to be able to use slicers so I can see the results per region, Month, week or staff member (or a combination of the above)
As everyone works a 40 hour week, I used the below formula to show the percentage of productivity per entry, but not sure if I really need to do this.
=IF([#Productive]="Yes",(100/40)*[#[Hours]],0)
Using this on a pivot table I was able to show the productivity of each staff member per week, but this is not really what I am after.
Is there a formula or VBA that I could use to work out the productivity in total and then filter it down accordingly. As this table will continuously grow during the year, I don't think I should be hard coding in weeks or months into the formula.
I tried using SUMIF ( =SUMIF(RawData[Staff Member],A2,RawData[Productive %]) )to get a total of the productivity for each user, and put that into another table but that did not really work as it was giving me 281% etc as it was just a total and would not filter down to the selected month/week/year
I have tried using AVERAGE in a Pivot Table, but that just gave really weird results.
I am really at a loss on how I can do this, if it can be done at all.
Even as an alternative I would be happy to have it show 2 different results in different tables for months or weeks, which I could then filter down to Region/Staff member
I am completely at a loss and would really appreciate some guidance/assistance.
Many thanks
DD

How to calculate no of days where sales were made in MS excel using sumifs and countifs?

I am working on an excel sheet where I am required to calculate average number of days the stores in a city were able to make some sales. I am attaching a sample of the table for reference. The values in the cells represent the number of units sold(not relevant to this question).
Here across NY, two stores are present, and out of the total number of days in consideration (3*2), only 4 days some sales were made, making the average 66%.
Similarly for Paris, there exists only one store which was open across all days.
To arrive at the figures, I tried using nested countifs and SUMIFS , but did not receive the expected results. Also, in some of the older posts, users had suggested to use INDEX MATCH with SUMIFS, but I was not to get accurate results using these.
Can anyone help me to get the correct figures for Total days, and Days with some sale.
SUMPRODUCT SOLUTION
=SUMPRODUCT(--(A$2:A$5=A8)*--(C$2:E$5<>""))
=SUMPRODUCT(--(A$2:A$5=A8)*--(C$2:E$5<>"NO SALE"))
=ROUND(C8/B8,4)
First, according to your grid NY made sales on 4 of the 6 days. (NY1: Mon, Wed; NY2: Tues, Wed). Thus the average is not 50% but 66%.
Second, to get your formula. Assuming "Place" is in column A. Below is for NY, you can solve for the rest.
Total number of days:
In cell "C9": =COUNTIF(A2:A4,"=NY") * 3
Days with sales:
In cell "D9": =COUNTIF(C2:E2,"<>NO SALE") + COUNTIF(C4:E4,"<>NO SALE")

Excel - What is the best way to analyse the following data?

I'm looking for the best way to analyse the following data.
This is the amount in hours an employee has taken in a year and what remains. The data bars are a percent of hours taken from what they're allotted, shown in column K. Col I is how many hours they have left, and col J shows the cumulative holiday they've taken throughout the year.
I need the relevant info shown on one row where each row will be an employee's holiday history. Different employees have different hours and I need a way that shows who is in most need of taking holiday when that filtering from largest to smallest etc.
Where I find this tricky is if an employee had 10 hours allotted, and has taken 2 hours, that's 20%, which is the same if someone had 100 hours and has only taken 20 hours. But it's clearly more important that the second employee uses up some of their leave. I'm struggling with the best way to represent this.

Resources