value ranking based on multiple criteria - excel

I Need to rank Dealers based on their Sales value and in regards to the Group and Country they belong to per month. It should look like this:
DealerID Month Country Group SalesValue Ranking
12344 1 Germany Sales 120 1
23345 1 Schweiz Sales 140 3
23346 1 Schweiz Sales 160 2
23347 1 Schweiz Sales 180 1
12350 1 Germany Sales 110 2
In SQL it would be similar to a rank function combined with a Group by month Country and Group. How can I achieve this in Excel?
Thank you!!

Related

Sum a Column if it matches a Criteria in one formula - is it possible?

I have two columns of revenue figures of different brands: Example
US UK
Brand 1 100 0
Brand 2 200 50
Brand 3 100 40
Brand 4 0 20
What I am trying to do is SUM the UK column IF and only if US AND UK are bigger than 0 (Revenue>0), Therefore my output would be 90.
How do I do this in one formula - is it possible?
Thanks
Try SUMIFS() like.
=SUMIFS(C2:C5,B2:B5,">0",C2:C5,">0")

Count apple based on common ID between two tables

I have two Excel tables that look like this:
Table 1
A B C
ID Stocked Sale
1 shelf sold
5 display sold
9 shelf sold
12 shelf sold
13 shelf
Table 2
P Q
ID Stocked
a2 apple
88
83
1 apple
9 apple
I need to count the total number of apples by common ID, given that apples are:
stocked on the shelf in Table 1
sold in Table 1
So, the outcome has to be 2 apples.
Here is what I have tried thus far:
COUNTIFS(B:B, "shelf", C:C, "sold", Q:Q, "apple")
I can't figure out how to count by common id...
Something like this should work for you:
=SUMPRODUCT(COUNTIFS(A:A,REPT($P$2:$P$6,$Q$2:$Q$6="apple"),B:B,"shelf",C:C,"sold"))

How to combine vlookup and if else in Excel using formulas

I am trying to update the budget of resources for travelling in sheet 1 with their per day expenses in sheet2. I have to first verify the destination city, and then fetch the expenses of their travel from sheet 2 on the basis of the number of days they are travelling from (mentioned in sheet 1).
So, First the destination should be matched , once we get the row number (from sheet 2), then need to fetch the number of days from sheet 1, and on the basis of the number of days, fetch the expense from sheet 2
Sheet 1
Destination No of Days Total expenses(output)
City 1 1 150
City 2 3.5 200
City 3 2 400
Sheet 2
Destination Day 1 Day 2 Day 3 Day 4
City 2 100 150 175 200
City 1 150 250 350 450
City 3 200 400 600 800
I tried using vlookup, and nested if formula each, but I am not able to fetch the number of days
(IF(A2=Sheet2!$A$2,Sheet2!$B$2,IF(A3=Sheet2!$A$3,Sheet2!$B$3,IF(A4=Sheet2!$B$4,Sheet2!$B$4))))
The outcome is mentioned in the description. The column Total expenses in sheet 1 is the expected output.
Instead of VLookUp, try Index + Match
=INDEX(Sheet2!$B$2:$E$4,MATCH($A2,Sheet2!$A$2:$A$4,0),$B2)
Additionally you can use:
=SUMPRODUCT((Sheet2!$A$2:Sheet1!$A$4=A2)*(Sheet2!$B$1:$E$1="Day " & ROUNDUP(B2,0)),Sheet2!$B$2:$E$4)

DAX - Distinct SUM thru 2 dimensions

I am trying to calculate "Distinct Sum" in DAX Powerpivot. I already have found help here: http://stackoverflow.com/questions/22613333/dynamic-sum-in-dax-picking-distinct-values
And my query is similar but extended further. I am seeking to find solution for such distinct Sum, but via two additional dimension (Month + Country)
In data example below there is Revenue performance on Part Number granularity. in Data there is also Shop Dimension, however Revenue is repeating on shops, is duplicated.
In the post mentioned above there is following solution:
Support:=MAX(Table1[Revenue])
DistinctSumOfRev:=SUMX(DISTINCT(Table1[Part_Num]),[Support])
It is work perfectly if you use Filter/Column/Row: Country and Month.
But if aggregate for All countries, or show performance on whole quarter, then solution will set MAX Revenue thru all countries/Months for and Part Number, which is not correct.
How to include into above solution also those two additional dimensions.
Basically to tell DAX that unique combination is PartNum+Country+Month
Country Month Part_Num Shop Revenue
----------------------------------------
UK 1 ABCD X 1000
France 1 ABCD X 500
France 1 ABCD Y 500
UK 2 ABCD X 1500
UK 2 ABCD Y 1500
UK 1 FGHJ X 3000
France 1 FGHJ X 600
UK 2 FGHJ X 2000
Add a calculated column to your Table1:
PartNumCountryMonth = [Part_Num]&[Country]&[Month]
Then create your measure as follows:
DistinctSumOfRev:=SUMX(DISTINCT(Table1[PartNumCountryMonth]),[Support])
Update
Alternative solution, calculated column is NOT required:
DistinctSumOfRev :=
SUMX ( SUMMARIZE ( 'Table1', [Country], [Part_Num], [Month] ), [Support] )

Excel lookup same index different row

I have a formatted table that contains information about areas, including sales for the month (and a heap of other columns containing other details). The table is the basis for graphs and pivot tables.
There is a row per month for each area, e.g.:
A B C D
1 Area Month Sales TwoMonthAverage
2 North 1 400 Manually entered
3 West 1 500 Manually entered
4 South 1 200 Manually entered
5 North 2 200 <calculate??>
6 West 2 200 <calculate??>
7 South 2 200 <calculate??>
8 North 3 100 <calculate??>
9 West 3 900 <calculate??>
10 South 3 600 <calculate??>
Each month, I want to calculate the "2 month average" sales for an area (being the average of the current and previous months).
I need to know how to get the sales for the same area for the previous month. The table rows will not necessarily be in the same area or month order. Needs to work in Excel 2013 and 2010.
Thanks
Blair
You could perhaps use SUMIFS to get the sum of the past 2 months sale:
=SUMIFS($C$2:C5, $A$2:A5, A5, $B$2:B5, ">="&B5-1)
This in D5 will give the sum of values that:
Have values in cells A above and including the current row, and
Have the month above or equal to the current month - 1.
You then only need to divide by 2 to get the 2 month average.

Resources