How to get Budget amount from the beginning of the year through current day in Power BI - excel-formula

I need to calculate Projected Premium by Insurance Type.
The formula for calculation is:
Sum(Budget) - Sum(Budget thru current Day) * (1+BudgetVariance) + TotalPremium
BudgetVariance = (Premium - Budget tru current Day) / Budget tru current Day
Basically I got all variables I need (Thanks to Joe), but some of them don't calculate properly:
BudgetMTD =
VAR DaysOfMonth = MAXX(Dates, DAY(EOMONTH(Dates[Date], 0)))
VAR BudgetPerDayForMonth = SUM(BudgetData[Amount]) / DaysOfMonth
VAR DaysInMonthToToday = MAXX(Dates,
IF(Dates[Date] < TODAY(), DAY(Dates[Date]),
IF(Dates[Date] > TODAY(), 0,
DAY(TODAY())
)))
RETURN BudgetPerDayForMonth * DaysInMonthToToday
BudgetMTD should be 25,882,308 but it displays 30,148,763 (which is the total for 12 months).
Also BudgetVarianceMTD displays correctly for each month, but in a card I need it as:
(Premium - Budget tru current Day) / Budget tru current Day
Which is:
28,505,823 - 25,882,308 / 25,882,308 = 0.10136326

just a hint to get from beginning of the year to current day
DATEDIFF(month, '2017/01/01', GETDATE()) AS d

Related

Trying to show a full years amount based on a smaller fraction of the year's total

this is my first post.
Right now, I have a limited set of data ranging from the beginning of this financial year until now. I'm trying to show what a full year's worth of that data would look like.
For example, if the number is at 10, and the data range is from 1/07/2021 - 30/12/2021 (half the year), then the end output should be 20. Or for example, turn a 12 with 3/4 of the year date range to 16 for a full years' worth.
However, my current formula would end up with 15 (10 + "half") rather than (10 + 10)
Right now this is what I have, but I know there's something off on my logic, as the output is smaller than it should be:
D1+((364-(F1-E1))/365)*D1
where E1 is the start date and F1 is the end date, and d1 is the number for that date range
Thanks in advance
endDate - startDate will give you the number of days the data covers.
(endDate - startDate) / 365 will give you what fraction of a year the sample represents.
Let’s say this works out to be 30%, or 0.30.
annualValue * 0.30 = periodValue and therefore we know that periodValue / 0.30 = annualValue.
So there it is, the cell you want the Annual Value in should be:
= periodValue / ( ( endDate - startDate) / 365 )
I will leave it to you to replace each of the three named values in my example to be the correct cell references. I suspect that’s probably:
=D1/((F1-E1)/365) which is the same as (D1*365)/(F1-E1).
The easy way to remember this is that it’s just cross-multiplication.
periodValue / days is proportionate to annualValue / 365. Thus periodValue / days = annualValue / 365. Cross-multiply and you get periodValue * 365 = annualValue * days. Divide both sides by days and you get `annualValue = (periodValue * 365)/days.

Excel formula not working while trying to calculate overtime or lesser time

I need to create a formula which will return overtime/lesser-time of employees based upon time duration.
I want to put the formula in column Q.
The requirement is such that -
If Total Duration(column O) is 0, then OT Hours = 0.
If Total Duration is >12 and Employment Type = Contractor, OT Hours =
12-O6 else O6-12.
If Total Duration is >8 and Employment Type <> Contractor, OT Hours =
8-O6 else O6-8.
I have entered the following formula but it is not working.
=IF(O6<>0,((IF(AND(D6<>"Contractor",O6>8),O6-8,8-O6),IF(AND(D6="Contractor",O6>12),O6-12,12-`O6))),0)`
This should work for you:
=IF(O6=0,0,IF(D6="Contractor",IF(O6>12,O6-12,12-O6),IF(O6>8,O6-8,8-O6)))

Adding business days in a DAX time intelligence measure

I am writing a custom time intelligence measure in DAX to calculate a disbursement period which is 30 days + the following Friday from a payment. The solution below appears to work. However, I need to only include business/working days which prevents me from using the DATEADD() function.
How could I go about skipping the weekend days in the count of 30?
Expected Amount Disbursed =
CALCULATE([Total Agency Component Paid],
FILTER(ALL('Calendar'),
DATEADD('Calendar'[Date], 30,DAY) - MOD(DATEADD('Calendar'[Date], 30,DAY), 7) + 6 > MIN('Calendar'[Date]) &&
DATEADD('Calendar'[Date], 30,DAY) - MOD(DATEADD('Calendar'[Date], 30,DAY), 7) + 6 < MAX('Calendar'[Date])
)
An easy way to compute dates considering working days is to add a column to the Calendar table with the progressive number of working days. Assuming we have the column IsWorkingDay in our Calendar table this new calculated column can be defined as
WorkingDayNumber =
VAR CurrentDate = 'Calendar'[Date]
RETURN
SUMX(
FILTER(
'Calendar',
'Calendar'[Date] <= CurrentDate
),
'Calendar'[IsWorkingDay]
)
where IsWorkingDay contains 1 for working days or 0 for non working days.
Then to compute the date after 30 working days since the date in the current row context
VAR WorkingDayNumber = 'Calendar'[WorkingDayNumber]
VAR DatePlus30WorkingDays =
CALCULATE(
MIN( 'Calendar'[Date] ),
'Calendar'[IsWorkingDay] = 1,
'Calendar'[WorkingDayNumber] = WorkingDayNumber + 30,
REMOVEFILTERS( 'Calendar' )
)

DAX Calculate Year To Date - Year to Previous Month (year change)

Trying to figure out how to calculate the equivalent to YTD but up til previous month when year changes.
For example:
Date | Value
2018-10 | 100
2018-11 | 100
2018-12 | 100
2019-01 | 100
2019-02 | 100
2019-03 | 100
Results expected:
When 2019-03 is selected
YTD = 300 (accumulated from 2019-01- to 2019-03)
Previous month accumulated = 200 (accumulated from 2019-01 to 2019-02)
When 2019-01 is selected
YTD = 100
Previous month accumulated = 300 (accumulated from 2018-10 to 2018-12)
I've tried:
Value_Accum_PreviousMonth:=TOTALYTD([Value];Calendar[Date]) - [Value]
but with the change of year, it doesn't work
Any ideas?
Disclaimer - I created this solution using Power BI. The formula should transfer over to Excel/PowerPivot, but it may require some minor tweaks.
While the time intelligence functions of DAX are super useful, I seem to be drawn towards the manual approach of calculating YTD, prior year, etc. With that in mind, this is how I would solve your problem.
First, I would make a measure that is a simply sum of your Value column. Having this measure is just nice down the road; not an absolute necessity.
Total Value = SUM(Data[Value])
Next, for use to calculate YTD manually based of the prior month, we need to know two things, 1) what is the target month (i.e. the prior month) and 2) what is the year of that month.
If you are going to use those values anywhere else, I would put them into there own measure and use them here. If this is the only place they will be used, I like to use variables to calculate these kinds of values.
The first value we need is the selected (or max date in cases of no selection).
VAR SelectedDate = MAX(Data[Date])
With that date, we can calculate the TargetYear and TargetMonth. Both of them are simple IF statements to catch the January/December crossover.
VAR TargetYear = IF(MONTH(SelectedDate) = 1, YEAR(SelectedDate) - 1, YEAR(SelectedDate))
VAR TargetMonth = IF(MONTH(SelectedDate) = 1, 12, MONTH(SelectedDate) - 1)
Having all of the values we need, we write a CALCULATE statement that filters the data to the TargetYear and month is less than or equal to TargetMonth.
CALCULATE([Total Value], FILTER(ALL(Data), YEAR([Date]) = TargetYear && MONTH([Date]) <= TargetMonth))
Putting it all together looks like this.
Prior Month YTD =
VAR SelectedDate = MAX(Data[Date])
VAR TargetYear = IF(MONTH(SelectedDate) = 1, YEAR(SelectedDate) - 1, YEAR(SelectedDate))
VAR TargetMonth = IF(MONTH(SelectedDate) = 1, 12, MONTH(SelectedDate) - 1)
RETURN
CALCULATE([Total Value], FILTER(ALL(Data), YEAR([Date]) = TargetYear && MONTH([Date]) <= TargetMonth))

Calculate hours needed to balance account?

I have an accounts excel sheet where you input all your expenses, all your incomes (gst inclusive), and it calculates how you are placed (E.G. -$717.75 for the month).
I It also gives you the gst content to pay $taxableIncome*3)/23 and a rough guide as to how much income tax you should put away $taxableIncome*0.17.
You also tell the program what your hourly rate is.
I am wanting to add to the program to allow it to tell you that you need to work X more hours this month to balance.
This wouldn't be soo hard,
$deficit/$hourlyRate = hours needed to work except for each additional hour worked we need to add ($hourlyRate*3)/23 to the gst expense, and add $hourlyRate*0.17 to the income tax expense.
This is the part I don't quite get how to work out.
So given an hourly rate of $21.00+gst = $24.15/h and a deficit of $717.75 how can I work out how many more hours I would need to work?
basically I am wondering how I can do a formula of
0 <= [(x1+x2+x3...)-(y1+y2+y3...)] / z1
Where x1 must increase until the entire formula equals 0, but as x1 increases, so must y1 and y2
x. = Income Source
y. = Expense
z. = Hourly Rate (gst inclusive)
Note that while the excel formula would be useful I am not expecting people to do the work for me, just a generic overview in pseudocode will work.
So, set:
gross new wage incl. gst - new gst - new income tax) =
-(current income - current expense) or -(Y-E)
where -(Y-E) >= 0
gross new wage - (gross new wage * 3/23) - (gross new wage * 0.17) = -(Y-E)
gross new wage * (1 - 3/23 - 0.17) = -(Y-E)
gross new wage = -(Y-E) / (1 - 3/23 - 0.17)
new hours * gross wage rate (incl. gst) = -(Y-E) / (1 - 3/23 - 0.17)
new hours = (-(Y-E) / (1 - 3/23 - 0.17)) / gross wage rate
That works, doesn't it?

Resources