On a form, I have a chart that shows the Increase History of each employee (What rating they were given each year, and how much of an increase they got)
I can't post an image since I have less than 10 reputation, but I hope it's clear.
What I need is a similar graph, but for the history of each employee's salary. I have a StartingSalary field in IncreaseEmployeesQ, and an Increase field. It's complicated, all I've managed to do is this:
SELECT IncreaseEmployeesQ.LocalID, Sum([Increase]+[StartingSalary]) AS CurrentSalary
FROM IncreaseEmployeesQ
GROUP BY IncreaseEmployeesQ.LocalID;
But what this does is add the StartingSalary each time, since it's repeated in each year. and it gives me one value for each employee, instead of one value for each year so I can have a chart that tracks the progress of the employee's salary.
I tried going to the original IncreaesT instead of the query that has it and EmployeesT (IncreaseEmployeesQ), thinking maybe I can have a calculated field if I add a StartingSalary field in IncreaseT (It's originally in EmployeesT) and then link it in relationships and enforce referential integrity, but I kept getting an error message. After some research I gathered that the reason is because the two tables have different Primary keys, so I resorted to the Query.
Is the chart I'm aiming to get to even possible? a chart that shows how each employee's salary has been progressing since 2010? (that's as far back as my data goes)
-assuming that a query is the right way to get this done- The query I'm working on looks like this:
LocalID Increase Years StartingSalary
1 1000 2013 7000
1 500 2014 7000
1 0 2015 7000
1 500 2016 7000
2 0 2013 5000
2 500 2014 5000
2 500 2015 5000
2 0 2016 5000
What I want it to look like (so I make a chart later) is this:
LocalID Increase Years StartingSalary CurrentSalary
1 1000 2013 7000 8000
1 500 2014 7000 8500
1 0 2015 7000 8500
1 500 2016 7000 9000
2 0 2013 5000 5000
2 500 2014 5000 5500
2 500 2015 5000 6000
2 0 2016 5000 6000
If it turns out like this, I can make a chart that has the Years and the CurrentSalary for each employee.
But all I've managed to do is the code above, which gives me this result
LocalID Increase Years StartingSalary CurrentSalary
1 1000 2013 7000 30000
1 500 2014 7000 30000
1 0 2015 7000 30000
1 500 2016 7000 30000
2 0 2013 5000 21000
2 500 2014 5000 21000
2 500 2015 5000 21000
2 0 2016 5000 21000
I hope everything is clear now
You want a cumulative sum. One way to do this in MS Access uses a correlated subquery:
SELECT ieq.*,
(ieq.StartingSalary +
(SELECT SUM(increase)
FROM IncreaseEmployeesQ as ieq2
WHERE ieq2.LocalID = ieq.LocalId AND ieq2.Years <= ieq.Years
)
) as CurrentSalary
FROM IncreaseEmployeesQ as ieq
Related
I'm looking to create a prior rolling 4 quarter Median. Some entries have less than 4 quarters, some have more. I want this by Employee. Needs to account for different tenure for different employees.
Result for 2021-1 should represent the prior 4 quarters median (and not account for current quarter).
I was able to figure out a rolling average with partitioning but not sure how to tackle a rolling median.
Thanks!
Employee ID
Quarter
Sales
EXPECTED RESULT
A
2020-1
1000
NULL
A
2020-2
2000
1000
A
2020-3
3000
1500
A
2020-4
4000
2000
A
2021-1
5000
2500
A
2021-2
4000
3500
B
2020-3
8000
NULL
B
2020-4
7000
8000
B
2021-1
6000
7500
B
2021-2
5000
7000
B
2021-3
1000
6500
C
2021-1
5000
NULL
C
2021-2
0
5000
C
2021-3
4000
2500
I'm using microsoft access and I need a sql query to return the top x (40 in my case) most recent sales for each neighborhood (NBHD). My data looks something like this:
PARID PRICE SALEDT SALEVAL NBHD
04021000 140000 1/29/2016 11 700
04021000 160000 2/16/2016 11 700
04018470 250000 4/23/2015 08 701
04018470 300000 4/23/2015 08 701
04016180 40000 5/9/2017 11 705
04023430 600000 6/12/2017 19 700
And what I need is the top 40 most recent SALEDT entries for each NBHD, and if the same PARID would show up in that top 40 twice or more, I only want the most recent one. If the rows have the same PARID and the same SALEDT, I need the only most expensive one. For this small set of sample data, I would get:
PARID PRICE SALEDT SALEVAL NBHD
04021000 160000 2/16/2016 11 700
04023430 600000 6/12/2017 19 700
04018470 300000 4/23/2015 08 701
04016180 40000 5/9/2017 11 705
I get row 2 (as it has a later SALEDT than row 1), row 4 (as it has a higher PRICE than row 3, and row 5 and row 6. Hopefully that is clear. Also, I'm using MS access SQL to do this, but wouldn't be opposed to some VBA solution if that is easier. Thanks in advance.
Here you go:
select a.parid, max(a.price)price, a.saledt, a.saleval, a.nbhd from #table a join (
select parid, max(saledt) saledt from #table
group by parid ) b on a.parid=b.parid and a.saledt=b.saledt
group by a.parid, a.saledt, a.saleval, a.nbhd
order by a.nbhd
In MS Access, you can do the following to get the 40 most recent entries for each neighborhood:
select t.*
from t
where t.salesdt in (select top 40 t2.salesdt
from t as t2
where t2.nbhd = t.nbhd
order by t2.salesdt desc
);
Your additional constraints are rather confusing. I'm not sure I fully follow them because I don't know what the columns really refer to.
I need a solution similar to this:
DAX running total (or count) across 2 groups
However slightly more complex.
I have the following:
(apologies for the layout - i can't post pictures)
Name Date Monthly Rev Total Rev Margin( % Rev)
Proj 1 1/08/2014 0 7000 15%
Proj 1 1/09/2014 1000 7000 15%
Proj 1 1/10/2014 1000 7000 15%
Proj 1 1/11/2014 1000 7000 15%
Proj 1 1/12/2014 0 7000 15%
Proj 1 1/01/2015 0 7000 15%
Proj 1 1/02/2015 2000 7000 15%
Proj 1 1/03/2015 2000 7000 15%
Proj 2 1/11/2014 0 16000 10%
Proj 2 1/12/2014 1500 16000 10%
Proj 2 2/12/2014 1500 16000 10%
Proj 2 3/12/2014 1500 16000 10%
Proj 2 4/12/2014 1500 16000 10%
Proj 2 5/12/2014 2000 16000 10%
Proj 2 6/12/2014 2000 16000 10%
Proj 2 7/12/2014 0 16000 10%
Proj 2 8/12/2014 2000 16000 10%
Proj 2 9/12/2014 2000 16000 10%
Proj 2 10/12/2014 2000 16000 10%
Monthly rev is the revenue received in a month, total is the total project value and margin is the percentage of revenue. The table is linked to a dates table by Date.
I need to show margin by date (there are other descriptive columns in the table for slicing) however the margin calc is not straightforward.
In an excel table it would look something like this:
Cumm simple margin | Completion| Cumm complex margin | Margin earnt
0 0% 0 0
150 20% 30 30
300 40% 120 90
450 60% 270 150
450 60% 270 0
450 60% 270 0
750 80% 600 330
1050 100% 1050 450
0 0% 0 0
150 11% 17 17
300 22% 67 50
450 33% 150 83
600 44% 267 117
800 56% 444 178
1000 67% 667 222
1000 67% 667 0
1200 78% 933 267
1400 89% 1244 311
1600 100% 1600 356
Where:
Simple margin is calculated on a cumulative basis as % of monthly Rev
Percentage complete of the project is calculated based on "active" months where revenue is earned
Cumulative simple margin is multiplied by the % complete
Actual margin earned in a particular month is the difference between two months.
Note that Monthly revenue is not necessarily continuous.
No idea how to recreate this in power pivot, any suggestions would be well received.
Cheers
Assuming
That your Project 2 data should run monthly from 1/11/2015 to 1/09/2015 (rather than individual December dates)
You have your data in a table called 'ProjectMargins'
Your DateDim table is called 'Reporting Dates'
Then these are the DAX Measures you need (although there may be simpler methods for achieving these results):
[MonthlyRev]:=SUM(ProjectMargins[Monthly Rev])
[ActiveMonth]:=CALCULATE(COUNTROWS('ProjectMargins'),FILTER('ProjectMargins',[MonthlyRev]>0))
[AllActiveMonths]:=CALCULATE([ActiveMonth],ALL('Reporting Dates'[Date]))
[Completion]:=DIVIDE(CALCULATE([ActiveMonth],FILTER(ALL('Reporting Dates'[Date]),'Reporting Dates'[Date] <= MAX(ProjectMargins[Date]))),[AllActiveMonths])
If you need to calculate TotalRev, from your Monthly Rev, Rather than it appearing in the original source table:
[TotalRev]:=IF(ISBLANK(MAX(ProjectMargins[Margin( % Rev)])),BLANK(),CALCULATE([MonthlyRev],ALL('Reporting Dates'[Date])))
[Rev%]:=MAX(ProjectMargins[Margin( % Rev)])
[Cumm Simple Margin]:=CALCULATE([MonthlyRev]*[Rev%],FILTER(ALL('Reporting Dates'[Date]),'Reporting Dates'[Date] <= MAX(ProjectMargins[Date])))
[Cumm Complex Margin]:=[Completion]*[Cumm Simple Margin]
[Previous Month Cumm Complex]:=CALCULATE([Cumm Complex Margin], DATEADD('Reporting Dates'[Date],-1,MONTH))
[Margin Earnt]:=IF([Cumm Complex Margin]>0,[Cumm Complex Margin]-[Previous Month Cumm Complex],BLANK())
NOTE: This assumes that the margin is never negative.
Ensure that the date field from the DateDim table is used in your pivot, not the date field from the Fact table.
This is Following details Called
For exam
Date type id acc amount
12/01/2 1 01 100 1000
12/01/2 2 02 200 3000
12/01/2 2 02 300 5000
Crystal report Total -----------------------
18000
But Actual Total for 9000 amount , How to solve issue
I tried in grouping also.
Pleas Help
Prakash
use the option Select Distinct Records in Database tab
I would like to create a non-VBA based solution to the following question:
How do I create a multi-series chart that will allow a user to select from a dropdown to change the data being graphed? I can do this already when the data series is contiguous; however, I'd like to be able to do it for non-contiguous data. Is this possible?
My data look something like this:
ID Salary Sal Min Sal Mid Sal Max Division Job Grade Job Subgrade Job
XXX 10000 5000 15000 25000 North 13 1 Programmer
XXX 12000 5000 15000 25000 North 13 1 Programmer
XXX 14000 5000 15000 25000 South 13 1 Analyst
XXX 11000 5000 15000 25000 South 13 1 Analyst
XXX 20000 5000 15000 25000 North 14 1 Super Programmer
XXX 25000 5000 15000 25000 North 14 1 Super Programmer
XXX 22000 5000 15000 25000 North 14 1 Manager
XXX 17000 5000 15000 25000 South 14 1 Manager
XXX 19000 5000 15000 25000 South 14 1 Manager
I would like to display Salary, Sal Min, Sal Mid, and Sal Max using a line graph. I would like the user to be able to select Job Grade, Division, and/or Job to determine what is charted. Is this possible? Would I somehow be able to do this if I used a pivottable or converted my data into a datatable?
Thanks.
Try this
http://processtrends.com/pg_interactive_chart_checkboxes.htm