I think maybe the way I'm asking this question is making it unclear. Here is another attempt:
I am trying to create a measure that counts the number of months it takes to reach an ending accounts receivable balance. As an example, I start with a measure that calculates an ending AR balance which is a calculation of values from different columns and tables and must look at every AR transaction regardless of date (that measure is already available.) What I now need to do is figure out how many months, counting backwards and including any fractional amount, starting with the most recent month (either selected or today's date) it takes to accumulate fees that add up to the ending ar balance. As an example, assuming we're looking at an AR balance at the end of 2016 $1,000:
Ending December AR Balance $1,000
December Fees: $200
November Fees: $300
October Fees: $400
September: $300
Using these values, the Months outstanding would be 3.33 (200 + 300 + 400 + (100/300).)
-- Original Question --
I'm trying to create a measure in DAX that calculates a Months Outstanding value. Essentially, the months outstanding calculation takes the final accounts receivable for an individual and counts back each month that it took to get to that value. As an example, if the final AR balance is $100 and each prior month had AR billings of $25 each month, the months outstanding would be 4 months.
I have come up with something that I believe is a start, but probably isn't even close:
Months Outstanding:=
VAR TotalBalance = [Ending Balance]
RETURN
CALCULATE(
DISTINCTCOUNT('Date'[Month]),
FILTER(
ALL('Date'[Month]),
[WIP Billings] + [AR Billings] < TotalBalance
)
)
In the above example, I'm trying to count the number of months it takes before the sum of WIP Billings and AR Billings exceeds TotalBalance (WIP and AR Billings are simply measures that are the sum of their respective columns.)
Thanks,
Eric
Edit
Here is the calculation for Ending Balance. The fact tables (Billing, Disbursement, Time, BilledDisbursement, BilledFee, MatterCredit) have references to Date, Matters, Clients, and Personnel
WIP Balance:=
ROUND(SUM(Disbursement[ToBillAmount])
+SUM('Time'[ToBillAmount])
-SUM(BilledDisbursement[ToBillAmount])
-SUM('BilledFee'[ToBillAmount])
-SUM('Matter Credit'[WIPBallance]), 2)
End WIP Balance:=
CALCULATE(
[WIP Balance],
FILTER(
ALL('Date'[Period]),
'Date'[Period] <= MAX('Date'[Period])
)
)
Ending AR Balance:=
CALCULATE(
SUM(Billing[ARAmount]),
FILTER(
ALL('Date'[Period]),
'Date'[Period] <= MAX('Date'[Period])
)
)
Ending Balance:= [Ending AR Balance] + [End WIP Balance]
Related
How can I go around to amending this MDX query
WITH MEMBER [Measures].[PanelSoldMonthsPre]
AS ' [In Charge Date].[In Charge Date Days in Month].CURRENTMEMBER.membervalue'
MEMBER [Measures].PanelSoldMonths
AS [Measures].[Panel Sold Days] / [Measures].[PanelSoldMonthsPre]
SELECT
[Measures].[Panel Sold Days], [Measures].PanelSoldMonths} ON COLUMNS,
NON EMPTY
([In Charge Date].[In Charge Year].Children, [In Charge Date].[In Charge Date Days in Month].Children) ON ROWS
FROM [Cube]
to..
a) bring back Year Month and corresponding number of days in month. At the moment its returning just the unique [In Charge Date Days In Months].
I want it to return the [In Charge Date Days In Months] for all 12 months for each [In Charge Date].[In Charge Year]
b) placing it as an expression in the calculations (calculated measures) section of the cube project. I decided to create them as 2 separate members. Clearly does not work since I get a return of [Measures].[PanelSoldMonthsPre] '#VALUE!' on the cube (excel workbook)
I have inherited a multidimensional OLAP cube (SQL Server 2014) and I currently need to extend it to produce the output I need.
Currently, I have a loan book by Report Date and then I need to get the proportion of the loan book by Geography.
An example hierarchy would be:
CY2018 > CY2018 Q3 > Jul CY2018 > Australia > Victoria > 3000
and then display the fields, Current balance and Proportion of Loan Book.
Or, alternatively I might want to see the proportion of loan book for Victoria over the entire loan book on a particular date.
Proportion of loan book is a calculation of the balance at a particular level in the hierarchy divided by the All balance for the loan book on a particular date.
For example:
If you are looking at Feb 2017 and Victoria, then I would like to see the proportion of the loan book for Feb 2017, Victoria over the entire balance for Feb 2017.
If you are looking at April 2018 and postcode 3000, I would like to see the proportion of the loan book for postcode 3000 in April 2018 over the entire balance for April 2018.
If you are looking at Jan 2016 and Australia, then you would see 100%, being the total loan book for that month.
The proportion of the loan book will always be calculated over the current month selected. It makes no sense to calculate a proportion of a loan book over multiple months or quarters etc, but I wouldn't care if that happened as a side-effect of what I am trying to achieve.
At the moment I have created a Calculated Member called Proportion of Loan Book as follows:
Case
When IsEmpty( [Measures].[Current Balance] )
Then 0
Else ( [Geography].[Geography Key].CurrentMember,
[Measures].[Current Balance]) /
( [Geography].[Geography Key].[All],
[Measures].[Current Balance] )
End
This produces something like this:
The problem with this is that it (1) doesn't take into consideration the current month, and (2) only shows a proportional value at the very bottom postcode level. I've fudged the figures here. but Victoria, for example, should show as 36% of the loan book for Jul 2018, whereas at the moment it shows as 100%.
How can I achieve this?
Ok, I have figured it out I think. Here's my code:
Case
When IsEmpty( [Measures].[Current Balance] )
Then 0
Else ( [Geography].[Geography Key].CurrentMember,
[Measures].[Current Balance]) /
( Root([Geography].[Geography Key].[(ALL)].[ALL]),
[Measures].[Current Balance] )
End
I don't know how correct it is; I pretty much stumbled around until something worked!
I am trying to create a query than can calculate the number of days, in a given month, that a particular stock item was unavailable (ie: No. = 0).
Currently, I have developed a query that can calculate the number of days it has been from today's date where stock has been unavailable but what I am trying to actually calculate is, during a month, how many days was stock quantity = 0. ie: Month of Jan - on Jan 5, Jan 7 and Jan 20 there was no stock for Item A - this means that the number of days out of stock was = 3.
Extra Details:
Currently, I am basing my query in determining stock levels of the last transaction (ie: if, at the last transaction, the QTY of Stock = 0) then calculate the number of days between the transaction date and today.
Select [StockItems].StockCode,
Case When SUM([StockItems].Qty_On_Hand)=0 Then (Datediff(day, GETDATE(),MAX([Transactions].TransactionDate))) ELSE 0 END AS 'Days Out of Stock',
From dbo.[Transactions]
INNER JOIN [StockItems]
ON [Transactions].[AccountLink] = [StockItems].[StockLink]
Where [StockItems].StockCode LIKE '%XXX%'
AND [Transactions].TransactionDate>31/10/14
Group By [StockItems].StockCode
My Thoughts
There are different sorts of transactions - one of which is a good received transaction. Perhaps it is possible to calculate the days where Stock Qty was zero and a transaction occurred then count that date until goods were received.
Thoughts?
Thank You.
SELECT COUNT([StockItems].Qty_On_Hand
From dbo.[Transactions]
INNER JOIN [StockItems] ON [Transactions].[AccountLink] = [StockItems].[StockLink]
WHERE [StockItems].Qty_On_Hand)=0
I have a financial cube and i have to calculate Daily Sales Outstanding as :
Number of Days between the selected month last date and the earliest transaction date when cummulative sum of Revenue from last date of the month till the date where sum revenue <= the debt amount for the date .
e.g
On 31/12/2009 my debt amount = 2,500,000
31-Dec-09 30-Nov-09 15-Oct-09 31-Oct-09
Revenue 1,000,000 1,000,000 500,000 1,0000
Cummulative sum of revenue 1,000,000 2,00,000 2,500,000 4,000,000
No of Days 31 30 16
On 15/Oct/09 cummulative revenue is 2,500,000 which equals my debt amount on that day
Count of Days = 31 + 31 + 16 = 76 Days.
In other words Sum Revenue from the selected date backwards until sum total equals or exeeds the total to date balance of the debtors.
Any help will be highly appreciated .
If i haven't explained clearly enough or if you need more information then please let me know.
Thanks in advance .
Shuchi.
Have you examined this blog: http://consultingblogs.emc.com/christianwade/archive/2006/04/30/MDX-Sprocs-and-Scripting_3A00_-An-Interesting-Example.aspx
He covers a few ways of approaching this, it sounds to me like a recursive problem, in that you need to 'walk backwards up along the calendar' adding up revenue, until you find the day where the added up revenue meets/exceeds the initial debt?
The above link should give you a few different approaches to tackle this, shout if you get stuck.
I have three tables:
Charges
Payments
Adjustments
Each has a value, called Amount. There are no allocations done on this data, we are assuming the oldest Payments are paying the oldest Charges or Adjustments. Each Amount could be +ve or -ve.
I need to produce a report which shows the age of the debt, based on the current balance being in debt, where the balance is the sum of each Amount in all tables. However, the age of the debt must be the Age of the current debt. If an account was in debit in October, but was zeroed in November and then in Debit in February, the Age of the Debt would be February. In need to provide a 30, 60, 90 day breakdown of each account whose balance is outstanding.
Sorry if this isn't clear, but if you've done it before you'll know what I mean. Any pointers?
Just been playing with a pen and paper. Is this as simple as:
Amnt Current Debt at Time = Sum(Debits to Time) - Sum (All Credits)
So in SQL:
Convert All +ve Charges, -ve Adjustments or -ve Payments to Debits (UNION)
Convert all -ve Charges, +ve Adjustments or +ve Payments to Credits (UNION)
For each of your age points, get the Sum of Debits to that point and subtract all of the credits for all time. (SUM and GROUP BY)
Any problems with this?