Forum Discussion
Divide by YEARFRAC syntax
Bhavesh:
Thanks for your reply. When I try that, I get the result "NaN" (not a number).
Any further advice on what i might be doing wrong?
Hi MojoGene,
Please follow the below screenshots for the solution. It is tested and working fine.
Create Calculated column for your hours column . if you already have one, you do not need to create one.Create another calculated column for yearfrac calculationYou can see the results in the screenshotCreate your desired measure for your final results.
Thanks & Regards,
Bhavesh
- MojoGene9 years agoPost Patron
Bhavesh:
Thanks once again. Unfortunately, it may not be possible for me to create a column for [Hours Paid]. In the underlying data, hours are only relevant to the calculation of the bill. Once hours are relieved (converted from WIP to AR), the hours are no longer important. So, when a payment on a bill is made, the line entries show the amount of the payment recorded against the amount of the bill, but the hours columns for these lines are shown as zero values.
In order to come up with a value for Hours Paid, I had to calculate this value by aggregating the data for each billing statement and then taking Sum(BillTable[Hours Billed]) and multiplying this value by a fraction represented by Sum([Fee Amout Paid]) / Sum([Fee Amount Billed]).
The measure actually looks like this:
Hours Paid = CALCULATE(IF(SUM(BillTable[FeeAmountDue])=SUM(BillTable[FeeBilled]),0,Sum([HoursBilled])*(Sum([FeeAmtPaid])/Sum([FeeBilled]))),FILTER(BillTable,[BillNumber]),Table_BasicCalendarUS[YearKey]=YEAR(TODAY()))
I hope this gives you some idea of why the calculated column does not seem possible in this setting.
- MojoGene9 years agoPost Patron
Bhavesh:
I think I stumbled on the solution. I created the Year Fraction column as you suggested and then divided the measure by the column in this manner:
Hours Paid Projected for Year = [Hours Paid]/CALCULATE(MIN(Table_ExtendedCalendar[Year Fraction]),Table_ExtendedCalendar[DateKey]=TODAY())
The results seem to be correct, so I hope there is no hidden flaw that I am overlooking. The actual function used (MIN, MAX, AVE) does not matter since the TODAY filter yields only one number.
Thanks again for your efforts.