What does "+1" mean in the following Qlik expression - qlikview

I am assuming the following expression means sum of sales for year 2009 and country Sweden, but I am not sure why +1 is being used, is it used as separator or it has any special meaning?
Sum({$<Year={2009}>+1<Country={'Sweden'}>} Sales)

1 in set analysis indicates that the calculation will ignore all selections made - returns a full set of data irrespective of user selections
In your case I can read the calculation like this:
Give me the union sum of Sales for:
Year={2009} - all sales for 2009. Respect the selections made (apart from Year)
1<Country={'Sweden'} - sales for Sweden but as if there are no selections applied across the app (if there are any selections made - ignore them)
Helpful links:
Set Modifiers (scroll down to Forced exclusion section)
Set analysis and set expressions (scroll down to Operators section)

Related

Edit 'no value' in crosstabs - Cognos Analytics dashboard

Is there a way to edit the 'no value' in the cells of a Cognos Analytics (11.0.13) dashboard crosstab visualization? I would like to change it into 0.
Thanks in advance.
My answer consists of two parts.
The first is of some techniques to do what you want to do. The second is of a caution about you really really need to understand the data to know if the values should be reported as zero rather than null.
Part the first
It depends on your data source and the provenance of the object.
If you are using a data module you can set a setting for the query item to replace the null with a zero.
If you are using an expression you could use the coalesce function to substitute a value then the source value is null. This could be used in place of whatever measure you are trying to use in your chart.
For example coalesce ( {some query item}, 0)
Coalesce takes any number of parameters and will return the value of those in the leftmost position unless it is null and then return the value for the next parameter, unless it is also null etc.
I'm assuming that you are using a file directly in the dashboard. My advice is that it might be a good idea to put it into a module, do your modelling there so that it is available in all your dashboards and reports and you can use it in conjunction with other data sources. Also, if you have a multi-sheet or multi-file source you have the ability to know how the relationships between the sheets were defined and correct them if need be. I have not had entirely good experiences with the soi disant smart relationship generation in multi-sheet files but you're using 11.0.13 and I don't think it's in there. (I'm using 11.1.5)
Part the second
For purists out there: A null is not a zero. There is a difference between a null and a zero. It's difficult for people without maths degrees (such as me, who trained as an accountant) to understand that but I have a fairly simple example which I think can show where a value is null and where it could be truly zero.
Assume that you are doing a month by month sales report for a car dealer. This time last year (i.e. in April 2019) you could be selling 2019 model year cars and some 2018 model year cars. You were not selling any 2020 model year cars because they were not released yet. In that case, the value ought to be null. Over time the number of sales of 2018 year cars would possibly be 0 as you would no longer have them in inventory to sell. In this pretend report I have a sale of 1 2018 car in February of this year.
Now, your report for 2019 will have nulls for the sales of 2020 year cars before the autumn (I think that's when they usually release new cars).
It is possible that the number of sale for April this year will be zero.
#E. van Dongen,
There is a way to set 'Missing value characters' property to '0' on Col Format option in CA 11.1.5 version. This option may be available in CA 11.0.13 as well.

MDX Retention Rate

I am new to OLAP and I have a pretty tricky assignment that I am not sure is possible in MDX:
I work for an insurance company and I have been asked to provide a Retention Rate calculation to compare the number of policies we have kept from one time period to another.
The data in our fact table consists of a month-end snapshots of each our policies and there is a flag to indicate whether they are currently active at that time.
So, in plain English, the steps to find the Retention Rate from December 2014 to December 2015 would be:
Get the set of active policy IDs as of December 2014 (set #1)
Get the set of active policies as of December 2015 that have the SAME policy ID as set #1 (set #2)
Divide set #2 by set #1 to get the Retention Rate
I am just not sure if it is possible to compare specific IDs from two different sets like that in MDX.
Any help would be greatly appreciated!!
This isn't something one would normally use MDX for, since it involves a condition at the detail level (PolicyID), and MDX is all about data in aggregate.
However, if you are willing and able to add a flag to your fact table/view it can be done. To address your exact question, you could simply add a bit (or int) flag into your fact table. For each record, the flag would be true (1) if the PolicyID is active now AND was active a year ago, and false (0) if it was not.
Then you can add a new measure to your cube that counts "retained policies", which is just the sum of the flag you just added, and then you can easily divide one measure by another.
If your needs are more complex than this one instance, there might be ways to add more complex data, but the point is that you have to create a way for your cube to be able to compare aggregations.

Qlikview guage chart - static variable

I am looking to create and use a gauge chart, but I am trying to figure how to compare selected vs the complete universe. For example, let's say I want to measure a monthly spending average of one department vs. the spending average of the entire organization. How do I make the organization average the segment marker? or make it a static variable that does not change with the selection?
As is the case with a lot of questions that pop up here, you can use set analysis to achieve this. In you gauge expression you could do something like this:
Assuming you are going to select one or more departments in the current state, you could do
percent_of_total_spending = avg({$}spending)/avg({1}spending)
The {} syntax is used in conjunction with the set identifiers $ and 1 to denote the the set of the current selections and the entire universe respectively. So the above expression will give you the percentage of average organizational spending for whatever departments you have selected.
You can use set modifiers in addition to the set identifiers to further customize what population you are including. See here for more information.
All you need to do is use set analysis and tell the expression what to ignore in the selections box.
Example:
Sum({<Month=, Year=>}Spending)
What the above is telling you is that it's taking the "Month" field and setting the selection for that specific expression to nothing, as well as the "Year" field. If you were to do the following:
Sum({<Month=, Year={"2014"}>}Spending)
It will calculate for that specific year, or even this
Sum({<Month=, Year={"2013","2014"}>}Spending)
Will make it calculate for both 2013 and 2014. Read up on the helpfile as well by pushing F1 and searching for set analysis.
So something like this will work for you
Sum(Spending) / Sum({<Month=, Year=>}Spending)

Adding a Standard Deviation Measure,Removing by range

In a Easy Cube layout i have a Product and Time dimension
my transaction cube has the unitary price of the product and the total value(quantity x unitary price)
sometimes when i got a product promotion(like :buy 2 get 3) we have the unitary price equal $0,01 for 1 record.
i want to remove from my average, maximum and minimun [measures] results all these records( $ 0,01)
i thinking about a standard deviation implementation, but this only work with my already set measures
i tried to add unitary price with a no aggregation measure (which would suit me) but i'm using standard edition
(and 'no aggregattion' its not available as measure type)
thanks for your time, sorry for my english
Arthur
Sao Paulo - Brazil
The better approach (the MDX way) would be to add an attribute, say "On promotion" with members "Promo" and "regular".
Then just by either not using the attribute (and hence using the All member, which aggregates "Promo" and "regular", you get all measures including the promoted products, or by using just the member "regular" in a filter or in the rows or columns, all measures would include only the regular products.
There are approaches for implementing this using your current cube model (probably using Filter), but they are complex to implement and slow.

Aggregation of an MDX calculated measure when multiple time periods are selected

In my SSAS cube, I've several measures defined in MDX which work fine except in one type of aggregation across time periods. Some don't aggregate (and aren't meant to) but one does aggregate but gives the wrong answers. I can see why, but not what to do to prevent it.
The total highlighted in the Excel screenshot below (damn, not allowed to include an image, reverting to old-fashion table) is the simplest case of what goes wrong. In that example, 23,621 is not the grand total of 5,713 and 6,837.
Active Commitments Acquisitions Net Lost Commitments Growth in Commitments
2009 88,526 13,185 5,713 7,472
2010 92,125 10,436 6,837 3,599
Total 23,621 23,621
Active Commitments works fine. It is calculated for a point in time and should not be aggregated across time periods.
Acquisitions works fine.
[Measures].[Growth in Commitments] = ([Measures].[Active Commitments],[Date Dimension].[Fiscal Year Hierarchy].currentMember) - ([Measures].[Active Commitments],[Date Dimension].[Fiscal Year Hierarchy].prevMember)
[Measures].[Net Lost Commitments] = ([Measures].[Acquisitions] - [Measures].[Growth in Commitments])
What's happening in the screenshot is that the total of Net Lost Commitments is calculated from the total of Acquisitions (23,621) minus the total of Growth in Commitments (which is null).
Aggregation of Net Lost Commitments makes sense and works for non-time dimensions. But I want it to show null when multiple time periods are selected rather than an erroneous value. Note that this is not the same as simply disabling all aggregation on the time dimension. The aggregation of Net Lost Commitment works fine up the time hierarchy -- the screenshot shows correct values for 2009 and 2010, and if you expand to quarters or months you still get correct values. It is only when multiple time periods are selected that the aggregation fails.
So my question is how to change the definition of Net Lost Commitments so that it does not aggregate when multiple time periods are selected, but continues to aggregate across all other dimensions? For instance, is there a way of writing in MDX:
CREATE MEMBER CURRENTCUBE.[Measures].[Net Lost Commitments]
AS (iif([Date Dimension].[Fiscal Year Hierarchy].**MultipleMembersSelected**
, null
, [Measures].[Acquisitions] - [Measures].[Growth in Commitments]))
ADVthanksANCE,
Matt.
A suggestion from another source has solved this for me. I can use --
iif(iserror([Date Dimension].[Fiscal Year Hierarchy].CurrentMember),
, null
, [Measures].[Acquisitions] - [Measures].[Growth in Commitments]))
CurrentMember will return an error when multiple members have been selected.
I didn't understand much of the first part of the question, sorry...but at the end I think you ask how to detect if multiple members from a particular dimension are in use in the MDX.
You can examine either of the two axes as a string, and use that to form a true/false test. Remember you can use VBA functions in Microsoft implementations of MDX.
I suggest InStr(1, SetToStr(StrToSet("Axis(1)")), "whatever") = 0 as a way to craft the first argument of your IIF.
This gets the set of members on axis number one, converts it to a string, and looks to see if a certain string is present (it returns the position of that string within the other). Zero means not found (so it returns true). You may need to use axis zero instead, or maybe check both.
To see if multiple members from the same dimension were used, the test string above would have to be more complicated. You want to know if whatever occurs once or twice. You could test if the first occurance of the string was at the same position as the last occurance (by searching backwards); though that could also mean the string wasn't found at all:
IIF(
InStr(1, bigstring, littlestring) = InStrRev(bigstring, littlestring),
'used once',
'used twice or not at all'
)
I came across this post while researching a solution for my own issue with grand totals of calculated measures over time when filters are involved. I think you could have fixed the calculations instead of suppressing them by using dynamic sets. This worked for me.