I need to change the total of an interest rate column. I mean, the total in the rate column is summarizing and I need the weighting average instead of the total. for example:
amount..........rate
450000..........8.75
390000..........8
15000...........2
855000(total)...8.29 (weighting average)
I'm trying to do it in the CALCULATIONS tab of the SSAS, but I cannot identify the total level for each group.
Please some ideas, point me to the right direction...
Thanks
JA
I would add a calculation to your source SQL views or DSV to calculate e.g. rate weight = rate * amount. I would then add that as a normal measure, Sum aggregation, hidden once you have finished testing.
Then the SSAS calculation becomes: rate weight / amount (wrapped in the typical Iif function to avoid dividing by zero).
At the leaf levels this returns weight. At any summary level it will return weighted average.
Related
I am currently attempting to use DAX queries to calculate the proportion of the balance attributed to each State in my analysis cube, from the following image:
I currently have a Sales table with a ReportDateKey that joins a ReportDate table that has a DateKey
If I use the following statement:
AllCurrentBalanceByDate:=CALCULATE([TotalCurrentBalance],ALLSELECTED())
It gives me the overall total, ignoring the date altogether, which is a useless figure.
If I enter the following query and display it in the excel spreadsheet:
AllCurrentBalanceByDate:=CALCULATE([TotalCurrentBalance],ALLSELECTED('Report Date'[Month]))
it is returning the same data as found in the Balance column. Again, useless. I need a total for each month, so that I can calculate the state balance / overall total for that month to get the proportion/percentage attributable to that State.
What am I doing wrong?
So if you want your measure to ignore whichever State is selected, you need to include the State columns in your ALL filter.
Also I suppose you want to use ALL instead of ALLSELECTED as your overall balance per month shouldn't be affected by external filters on state (but this depends on your use case)?
AllCurrentBalanceByDate:=CALCULATE(SUM([CurrentBalance]),ALL(Geography[StateName]))
I am trying to sum every line in a table summarizing it by two fields in webi.
I have a table with the following columns:
Risk, Year, AssessedBy, Weight, Value.
I have filtered the table by Year = 2018 and Risk = "01". Thus, I only have the info for that year and that risk.
Each person assessing has a different weight in the final valuation by risk and year. What I have done is divide the assessing person's weight by the total sum of every Weight in the table [ sum(weight) in block ].
The problem is that when I delete the filter, the in block clause makes that the total sum of the weights changes to the total sum of the weights for every year in the table.
I would need something to calculate the total sum for each year and risk.
Just solved it! Just see Sumal Kunir answer: http://www.forumtopics.com/busobj/viewtopic.php?p=971131
=sum([Var_a] for each(Dimension;dimension)) In (Demension)
where var_a is the measure, foreach defines a background to base in and in defines the level at which you want to aggregate.
I have the following situation (in SSAS):
http://i.imgur.com/D1xrYrv.jpg
Cube with two dimensions (Time / Alpha) and one measure (X)
Columns A - G is the result of the cube, with column G as the total sum.
How to get the average (like column H) instead of sum in SSAS?
It's called "Time state rollup" in Cognos, but how to get this in Microsoft?
I would try the Measure Aggregation Function: AverageOfChildren.
In my scenario I need to calculate Total Distance Covered, but in the data i get there is only the Total Distance Accumulated , so if i want to know what is total distance covered say in year 2012 i need to get :
Total Distance Accumulated at END of Year 2012 - Total Distance Accumulated at END of Year 2012
And I want this calculation to work on any level of the Date Dimension(which in this case is down to Day level), so a user can place it in a pivot table and just play with it as he sees fit.
I am not sure how or if i can do such a calculation member using MDX on the cube level.
Also, I'm working with SQL 2008 Standard addition, so no semi additive functions available.
WITH MEMBER [Measures].[Total Distance Travelled] as
(
SUM(CurrentDateMember([<hierarchy>],'["<hierarchy>"]\.[<DATE Level>]\.[yyyy-mm-dd]').lag(x):CurrentDateMember([Dates.Time],'["Dates.Time"]\.[Date]\.[yyyy-mm-dd]'),[Measures].[Total Distance Accumulated]))
Select {[Measures].[Total Distance Travelled]} On 1
from [<cube name>]
'x' here is number of days, If you are viewing across month level x would be no.of months
This would basically sum the distance right from specified date
I have cost center allocation data that is currently fully populated, one record per day, each with one cost center dimension key. The cube has a head count measure (the data is set to "1"), and the aggregate function is set to "LastChild". This means that a head count report will count a person only once in a cost center in any given time period.
Introducing partial allocations - a new measure will have a percentage value for the allocation, allowing for multiple concurrent cost centers where the allocation should add up to 100% (with "day" being the granular level). I am trying to figure out how to configure the aggregation over other time periods. I thought that "Average" should work just fine, i.e. a person who is allocated to a cost center at 50% for half the time period will be reported at 25% for that period.
The problem that I see is that my facts are not populated for days where the allocation to a cost center was 0%. To illustrate:
Employee1 CostCenterA 1/1/2013 50%
Employee1 CostCenterB 1/1/2013 50%
Employee1 CostCenterA 1/2/2013 100%
Employee1 CostCenterA 1/3/2013 100%
... etc with 100% in CostCenterA for all days
The above data on a report by month shows 50% for the allocation to CostCenterB, even though the person was only allocated for one day, and the average percentage on a monthly basis should be 1.6%.
I suppose I could generate the 0%-allocations in the data, but my fact table would explode as a result, so I'd much rather change how the "average" aggregation treats percentage values in facts that are sparsely populated, i.e. the average should be calculated based on the number of granular units in the reporting period (days in the month, in this case 0.5/31), not the number of rows in the fact table (0.5/1). Can this be done in SSAS?
If the measure with the average allocation is off by a factor that is proportional to the "sparseness" of my facts, i.e. the ratio of days in a period and actual fact rows, then it can be corrected as follows:
adjusted average allocation =
(calculated average allocation) * (fact count)/(number of days in period)
I created two new hidden measures, one named [Fact Count] for the fact count (a measure using the AggregateFunction "Count") and a calculated measure named [Days In Period Count] for the number of days, using the expression
COUNT(Descendants([Date].[Calendar].CurrentMember,5),INCLUDEEMPTY)
with [Calendar] being the name of the hierarchy in my Date dimension.
Finally, I added a calculated measure that implements the corrective formula:
[Measures].[Allocative Head Count]/
(
[Measures].[Days In Period Count]/[Measures].[Fact Count]
)
and named it [Adjusted Average Allocation]. This I can now use in reports and it appears to somewhat approximate the average cost center allocation over longer periods.
The formular for [Days In Period Count] btw does not work for the row totals when filters are involved. I opened another question for this.