SAP Web Intelligence Sum Product - sum

I'm new here. I have a problem generating a forecast. I have different projects with different planned and actual data.
In one report I want to show the projects in each line and in another report I want to show the aggregated overall result of all projects.
I tryed:
=sum([FORECAST COST]) in ([Project])
=sum([FORECAST COST]] foreach ([Project])
=runningsum([FORECAST COST)] foreach ([Project])
any idea?

Try this formula in Forecast cost column:
=If [FORECAST COST] InList ("project a";"project b";"project c";"project d";"project e") Then "Sum" Else [FORECAST COST]
This applies to BO4.0. If you have 4.1 and higher, you can use grouping.

Related

DAX % of total count if measure qualifies criteria

DAX 2013 standalone power pivot.
I have a sales table with Product and Brand columns, and Sales measure which explicitly sums up sales column.
Task in hand: I need to create 1 measure RANK which would ...
if Product is filtered expressly, then return count of Products that have higher or equal sales amount, divided by total count of products.
If it's a subtotal brand level, show the same but for brands.
My current approach is using RANK and then MAXX of rank which seems working but a no-go - slow nightmare. Excel runs out of memory.
Research: it's been a week. This is the most relevant post i found anywhere, this question here , but it's in MDX.
In my example picture, I'm showing Excel formulas with which I can get to the result. Ideally there shouldn't be any helpers, 1 formula for all.
I.E.
RANK:=IF( HASONEFILTER(PRODUCTS[PRODUCT], HELPER_PROD, HELPER_BRAND)
where HELPER_PROD part would be something like this - need to find a way to refer to "current" result in pivot table like Excel does using [#[...:
HELPER_PROD:=COUNTX(ALL(PRODUCTS), [SALES]>=[#[SALES]]) / COUNTX(ALL(PRODUCTS))
HELPER_BRAND:=COUNTX(
DISTINCT(ALL(PRODUCTS[BRAND])),
[SALES]>=[#[SALES]]) /
COUNT(DISTINCT(ALL(PRODUCTS[BRAND]))
You can use the "Earlier" function to compare with the current record.
ProductsWithHigherSales:=CALCULATE(countrows(sales),
FILTER(all(Sales),
countrows(filter(Sales,Sales[Sales]<=EARLIER(Sales[Sales])))
))
Using Earlier function in measures: can-earlier-be-used-in-dax-measures
Used workbook: Excel File

Remaining calculation

I have a database in MS Office Access, used to manage stock. I have two types of transactions Addition = when there is a new item, removal = when items go out.
I need to add a section that will return remaining quantity in stock after I add or remove items. What would you suggest?
Note: I have many items, not one item
What do you mean by 'add a section'? Calculate inventory balance when needed. Search topic 'inventory balance'. Could do an aggregate query for stock received and another for stock used then use those queries in another to calculate difference. Or consider:
SELECT [Transaction Item], Sum(IIf([Transaction Type]="Addition", [Quantity],0)) - Sum(IIf([Transaction Type]="Removal", [Quantity],0)) AS Balance GROUP BY [Transaction Item];
A running balance on form is not practical (not to mention just plain hard to do) especially if records are filtered or sorted. However, you could show the net balance of each item with DSum() domain aggregate function. Try this in the [Inventory Transactions Extended] query.
Balance: Nz(DSum("Quantity","[Inventory Transactions]","[Transaction Type]=1 AND [Transaction Item]=" & [Transaction Item]),0)-Nz(DSum("Quantity","[Inventory Transactions]","[Transaction Type]=2 AND [Transaction Item]=" & [Transaction Item]),0)
The calc will update as soon as record is committed to table. Record is committed when moving to another record, closing form, or by code to save record.
I NEVER build lookups in tables. I want to see the real values when I view tables.
Don't really need to pull [Inventory Transactions] ID field individually to define sort criteria. This is primary key index and records will sort by this field by default. So pulling in the field with the query * wildcard will produce the same sort.

MDX - Count of Filtered CROSSJOIN - Performance Issues

BACKGROUND: I've been using MDX for a bit but I am by no means an expert at it - looking for some performance help. I'm working on a set of "Number of Stores Authorized / In-Stock / Selling / Etc" calculated measures (MDX) in a SQL Server Analysis Services 2012 Cube. I had these calculations performing well originally, but discovered that they weren't aggregating across my product hierarchy the way I needed them to. The two hierarchies predominantly used in this report are Business -> Item and Division -> Store.
For example, in the original MDX calcs the Stores In-Stock measure would perform correctly at the "Item" level but wouldn't roll up a proper sum to the "Business" level above it. At the business level, we want to see the total number of store/product combinations in-stock, not a distinct or MAX value as it appeared to do originally.
ORIGINAL QUERY RESULTS: Here's an example of it NOT working correctly (imagine this is an Excel Pivot Table):
[FILTER: CURRENT WEEK DAYS]
[BUSINESS] [AUTH. STORES] [STORES IN-STOCK] [% OF STORES IN STOCK]
[+] Business One 2,416 2,392 99.01%
[-] Business Two 2,377 2,108 93.39%
-Item 1 2,242 2,094 99.43%
-Item 2 2,234 1,878 84.06%
-Item 3 2,377 2,108 88.68%
-Item N ... ... ...
FIXED QUERY RESULTS: After much trial and error, I switched to using a filtered count of a CROSSJOIN() of the two hierarchies using the DESCENDANTS() function, which yielded the correct numbers (below):
[FILTER: CURRENT WEEK DAYS]
[BUSINESS] [AUTH. STORES] [STORES IN-STOCK] [% OF STORES IN STOCK]
[+] Business One 215,644 149,301 93.90%
[-] Business Two 86,898 55,532 83.02%
-Item 1 2,242 2,094 99.43%
-Item 2 2,234 1,878 99.31%
-Item 3 2,377 2,108 99.11%
-Item N ... ... ...
QUERY THAT NEEDS HELP: Here is the "new" query that yields the results above:
CREATE MEMBER CURRENTCUBE.[Measures].[Num Stores In-Stock]
AS COUNT(
FILTER(
CROSSJOIN(
DESCENDANTS(
[Product].[Item].CURRENTMEMBER,
[Product].[Item].[UPC]
),
DESCENDANTS(
[Division].[Store].CURRENTMEMBER,
[Division].[Store].[Store ID]
)
),
[Measures].[Inventory Qty] > 0
)
),
FORMAT_STRING = "#,#",
NON_EMPTY_BEHAVIOR = { [Inventory Qty] },
This query syntax is used in a bunch of other "Number of Stores Selling / Out of Stock / Etc."-type calculated measures in the cube, with only a variation to the [Inventory Qty] condition at the bottom or by chaining additional conditions.
In its current condition, this query can take 2-3 minutes to run which is way too long for the audience of this reporting. Can anyone think of a way to reduce the query load or help me rewrite this to be more efficient?
Thank you!
UPDATE 2/24/2014: We solved this issue by bypassing a lot of the MDX involved and adding flag values to our named query in the DSV.
For example, instead of doing a filter command in the MDX code for "number of stores selling" - we simply added this to the fact table named query...
CASE WHEN [Sales Qty] > 0
THEN 1
ELSE NULL
END AS [Flag_Selling]
...then we simply aggregated these measures as LastNonEmpty in the cube. They roll up much faster than the full-on MDX queries.
It should be much faster to model your conditions into the cube, avoiding the slow Filter function:
If there are just a handful of conditions, add an attribute for each of them with two values, one for condition fulfilled, say "cond: yes", and one for condition not fulfilled, say "cond: no". You can define this in a view on the physical fact table, or in the DSV, or you can model it physically. These attributes can be added to the fact table directly, defining a dimension on the same table, or more cleanly as a separate dimension table referenced from the fact table. Then define your measure as
CREATE MEMBER CURRENTCUBE.[Measures].[Num Stores In-Stock]
AS COUNT(
CROSSJOIN(
DESCENDANTS(
[Product].[Item].CURRENTMEMBER,
[Product].[Item].[UPC]
),
DESCENDANTS(
[Division].[Store].CURRENTMEMBER,
[Division].[Store].[Store ID]
),
{ [Flag dim].[cond].[cond: yes] }
)
)
Possibly, you even could define the measure as a standard count measure of the fact table.
In case there are many conditions, it might make sense to add just a single attribute with one value for each condition as a many-to-many relationship. This will be slightly slower, but still faster than the Filter call.
I believe you can avoid the cross join as well as filter completely. Try using this:
CREATE MEMBER CURRENTCUBE.[Measures].[Num Stores In-Stock]
AS
CASE WHEN [Product].[Item Name].CURRENTMEMBER IS [Product].[Item Name].[All]
THEN
SUM(EXISTS([Product].[Item Name].[Item Name].MEMBERS,[Business].[Business Name].CURRENTMEMBER),
COUNT(
EXISTS(
[Division].[Store].[Store].MEMBERS,
(
[Business].[Business Name].CURRENTMEMBER,
[Product].[Item Name].CURRENTMEMBER
),
"Measure Group Name"
)
))
ELSE
COUNT(
EXISTS(
[Division].[Store].[Store].MEMBERS,
(
[Business].[Business Name].CURRENTMEMBER,
[Product].[Item Name].CURRENTMEMBER
),
"Measure Group Name"
)
)
END
I tried it using a dimension in my cube and using Area-Subsidiary hierarchy.
The case statement handles the situation of viewing data at Business level. Basically, the SUM() across all members of Item Names used in CASE statement calculates values for individual Item Names and then sums up all the values. I believe this is what you needed.

MDX ignoring Excel filter

I'm just starting to get my head around MDX and I'm having trouble with a calculated member. I'm using the following MDX:
IIF(
ISEMPTY((Axis(1).Item(0).Item(0).Dimension.CurrentMember, [Measures].[Qty]))
,NULL
,([Product].[Product Code].CurrentMember.Parent, [Measures].[Qty])
)
What I'm trying to do is get a total quantity of the group of products displayed in a cube. I then use that total to divide by each product's quantity to get a "percent of total" measure. The above MDX does correctly return the total quantity of products displayed in any dimension. However, when a user in Excel changes the filter on which products are displayed, the MDX above still displays the total quantity for the whole group, ignoring which products the user has checked. I assume I'm lacking some basic understanding of MDX, how do I get the calculated measure to account for the product codes the user has selected in Excel?
With Visual Studio SQL Server Data Tools (if you are using that tool), you can browse to your cube, select the Calculations tab, and under Calculations Tools > Templates there is a template "Percentage of Total". The MDX this tool provides is flexible so that the percentage adjusts with the attributes of the hierarchy you've pulled into the pivot.
Case
// Test to avoid division by zero.
When IsEmpty
(
[Measures].[<<Target Measure>>]
)
Then Null
Else ( [<<Target Dimension>>].[<<Target Hierarchy>>].CurrentMember,
[Measures].[<<Target Measure>>] )
/
(
// The Root function returns the (All) value for the target dimension.
Root
(
[<<Target Dimension>>]
),
[Measures].[<<Target Measure>>]
)
End
I found this option to work when developing to achieve what you've mentioned.

Moving Annual Total SSAS

I have a cube and I want to create a MAT column. This column is then expected to show up in the same way as a regular metric would.
How do I create a column that is a Moving Annual Total in SSAS?
A walkthrough / demo would work as well.
Since you haven't really specified anything (MDX or actually in your cube) I will assume you mean in your cube. If i were you I would write a calculated member and then slide it over when browsing or in your reports. It would be something like this
WITH
MEMBER
[Measures].[Rolling Total]
AS
'SUM ( { [Time].CurrentMember.Lag(3) : [Time].CurrentMember },
[Measures].[Warehouse Sales])'
Then you could do something like this:
SELECT
CrossJoin({ [Time].[Quarter].Members },{[Measures].[Warehouse Sales],
[Measures].[Rolling Total]}) ON COLUMNS,
{[Warehouse].[All Warehouses].[USA].Children} ON ROWS
FROM
[Warehouse]