(SOLVED using VLOOKUP) Tiered/Nested IF clauses within one cell - vlookup

Imagine a tiered revenue sharing scheme like this:
Revenue up to 10000 get 100% of it.
Revenue up to 12000 get the above plus 80% of the amount above 10000.
Revenue up to 14000 get the above plus 60% of the amount above 12000.
Revenue up to 16000 get the above plus 40% of the amount above 14000.
Revenue over 16000 get the above plus 20% of the amount above 16000.
E.g. A revenue of 13000 will get you a share of 10000+0.82000+0.61000 = 12200.
I tried making a table (each threshold a column) and calculate the individual fractions using IF clauses and then add them all up. It is very cumbersome. I would like to use only two cells with the entire calculation done in one cell, hard-coded.
If at all possible, extra bonus points if I can have the threshold values (10000, 12000, etc) and fractions (100%, 80%, etc.) in separate cells as parameters for the calculation, maybe something like an array-function?
Thank you very much in advance!

Start your lookup table with a value of 0 and a rate of 100%. In this case, VLOOKUP() with the last parameter equal to 1 will correctly find the required row.
In order not to recalculate all the above rows for each of the values, calculate them in advance and place them in the table as an additional column.
For the first line it will be 0, and calculate all subsequent values using a formula like =C2+(A3-A2)*B2
For such a table, a not very complicated formula will return the correct result:
=(<revenue>-VLOOKUP(<revenue>;<lookup_table>;1;1))*VLOOKUP(<revenue>;<lookup_table>;2;1)+VLOOKUP(<revenue>;<lookup_table>;3;1)
The third parameter in the VLOOKUP() functions increases from left to right: 1 - the base amount, 2 - the interest rate, 3 - the calculated markup for reaching the previous levels.
For the data shown in the figure, the formula is used
=(E2-VLOOKUP(E2;$A$2:$C$7;1;1))*VLOOKUP(E2;$A$2:$C$7;2;1)+VLOOKUP(E2;$A$2:$C7;3;1)

Related

Summing totals from same date ranges, and getting the range value for those totals

I have the following data currently in PowerBI
This is totals for multiple entities that are under the same location (ID 1).
What I would like to produce is the following
Which is the summation of the 3 totals over time, with start and end dates of when they applied.
I will eventually try to use this to show a trending chart over time for how the totals changed.
Is something like this even possible in PowerBI and/or DAX to first produce the results and then report a trend line like that? The trend line in this example would just have the 3 data points.
The only thing I can think of right now is to extrapolate out each range to 1 day at a time per original screenshots rows, and make the granularity of the chart daily, instead of ranges like this. Then the summation becomes a lot simpler as its just be ID and Date. Only concern is the data volumes that will be produced by extrapolating this out by days like that.

PowerBI dynamic filter for period

I would need a report that shows variances for the current period, next period, half-year and year-end.
There is a period filter from 1 to 12 representing the periods in a year.
I can build up a table that shows the difference:
for the current period (can be amended based on the period filter)
for full-year (using ALL function to ignore the period filter)
But I don't know how to write a dax that filter just for the first 6 periods as half-year.
Or add one to the current period filter to shows the next period-related variance.
Also, that should be dynamic. This means if I adjust the period filter it should show always be the next period. (If the filter is set for 1 to 4 it returns 1 to 5; set 2 to 7 returns 2 to 8).
Could you please help me with how to do that?
Thanks
So, let's say we have 2 databases.
The plan for the current year and the actuals:
Excel
And I would like to see the difference between them in one visualization.
If the period set is 1 to 2:
for the current period shows: sum plan (1-2) - sum Actual (1-2)
next period: sum plan (1-3) - sum Actual (1-3)
Half Year: sum plan (H1) - sum Actual (H1)
FY: sum plan (1-12) - sum Actual (1-12)
I am not able to understand exact query but it seems that as per your given examples it's more related to time intelligence formulas in PowerBi to given results based on specific time frames. (YTD, QTD etc)
Below is the link to address your query via time intelligence formula
https://www.analyticsvidhya.com/blog/2020/08/time-intelligence-power-bi/

How to sum two columns if one column might have two different variables which would call for a different calculation

I need to create a SUM() column (summing two columns), the issue I'm having in the second column might have a result which needs to multiply the first column or it might have a result which needs to be added to the result in the first column.
Example
First Column (Estimated Costs)
50,000
100,000
5,000
Second Column (contingency amounts)
5%
10,000
10%
5,000
The first column will always have numbers. The second column will either have a percentage or an amount. I need to create a formula to sum either possibility. Is this possible or do I need to create two different sum columns for either scenario?
I tried using an OR statement with the SUM() formula but it didn't seem to work.
I understand that you're providing the cotingency cost of the estimate on 2 different ways as a percentage of the estimate or as a lumpsum amount to be added to the estimate.
You should use IF() to differentiate the two operations you have to apply. As the two types of values are very different on the contingency column the #BigBen suggestion of Value>1 should work perfectly well as you won't be adding less than $1 buck as a contingency. Therefore the formula will be:
=IF(B1>1,A1+B1,A1*(1+B1))
Column A is Estimated Costs, Column B is Contingency.

Count number of records totalling a given percentage of the overall total in Power BI

I'm relatively new to power bi so please bear with me!
I have a report which looks at information about individual stores of a given customer.
One of the requirements is to show the % that the top N stores constitute to the overall total, for example the top 1 store makes up 30% of overall sales, top 5 stores make up 65% of the overall total, etc. I can achieve this easily using the 'Top N' filter function.
The other requirement is to count the number of stores which total 80% of the overall total sales. For example, we have a total of 100 stores for a given account which generate a revenue of £10,000. The top 60 stores generate a revenue of £8,000, therefore 60 of the 100 stores make up 80% of the overall sales.
Hopefully that makes sense! Is this possible within power bi? If so could someone point me in the right direction?
Thanks in advance for your help.

Marketing penetration in OLAP cube - Help with specific MDX measure definition

I am pretty new to MDX but I know what I want accomplish but its proving very hard. Basically, I have a dataset where each row is a sale for a customer. I also have postcode data and the UK population at each ward.
The total population in each ward is then divided by the count of the wardcode within the data set - e.g. ward A had a population of 1,000. I have ten customers who live in ward A and so the population value is therefore 1,000/10.
So as long as there are no other dimensions selected, only the region hierarchy, I can then drill up and down and the population penetration as count of customers / calculated population value is correct. However, as soon as I introduce more dimension the total population will not sum to its true value.
So I therefore need to do the calculation above within the cube and I am trying to find the MDX function(s) to do this.
Esentially something like -
step 1) sum the number of ward codes (the lowest level of the Geographic hierarchy) and group this by the distinct ward code, eg wardcodeA = 5, wardcodeB=10 etc.
Step 2) Then take the population in each ward (which could be stored as the total at ward level and taking the average) and then divide this by the result of the previous step
step 3) sum the results from each ward at the currently select Geographical level
The fact other dimensions are changing the value of customers / population means that something in your modeling is wrong.
You should have a fact table (can be a view/concept) like this :
REGION_ID, CUSTOMER_COUNT, POPULATION_COUNT
Once you got this create a fact table and a specific measure for counting customers and population with a single dimension linked. This is the main point, do not link your measures with dimension that are not needed.