MDX Slicer axis dimension properties - mdx

How do I request dimension properties on the slicers axis / WHERE section of an MDX request. I need the CHILDREN_CARDINALITY property of a member. Any help would be appreciated.

You can't. But, you can create a Set in WITH section using that property, something like this:
WITH
SET [Set Filter] As Filter({Dimension.Members}, Dimension.CurrentMember.Properties("PROPERTY_NAME") = "Value")
Select {} On 0, {} On 1 FROM [Cube]
WHERE ([Set Filter])

Related

How do I get the Index of an UltraComboEditor ValueList Item?

I have an UltraComboEditor named ddltype
I set the values with an Enumeration:
ddlType.Items.Add(SalesPaymentType.CashPayment.Value, SalesPaymentType.CashPayment.DisplayName)
ddlType.Items.Add(SalesPaymentType.CheckPayment.Value, SalesPaymentType.CheckPayment.DisplayName)
ddlType.Items.Add(SalesPaymentType.CreditCardPayment.Value, SalesPaymentType.CreditCardPayment.DisplayName)
When I try to set the SelectedIndex with
ddlType.SelectedIndex = ddlType.Items.ValueList.FindString(SalesPaymentType.CashPayment.DisplayName)
It returns 0 not found. It is not finding my entry.
Any enumerated values can be added to the UltraComboEditor control as below:
ultraComboEditor1.Items.Add(new ValueListItem(value, value.ToString))
One of the ValueListItem() constructors gets data value and display text.
To find item by string:
ultraComboEditor1.SelectedIndex = ultraComboEditor1.FindString(SalesPaymentType.CashPayment.ToString)
But more reasonable to use the FindByDataValue():
ultraComboEditor1.SelectedItem = ultraComboEditor1.ValueList.FindByDataValue(SalesPaymentType.CashPayment)
Pay attention, the FindByDataValue() requires a value, but not a text.

Dataframe Row(sum(fld)) to a discrete value

I have this:
df = sqlContext.sql(qry)
df2 = df.withColumn("ext", df.lvl * df.cnt)
ttl = df2.agg(F.sum("ext")).collect()
which returns this:
[Row(sum(ext)=1285430)]
How do devolve this down to just the discreet value 1285430 without it being a list Row(sum())?
I've researched and tried so many things I'm totally stymed.
No need for collect:
n = ...your transformation logic and agg... .first().getInt(0)
Access the first row and then get the first element as int.
df2.agg(F.sum("ext")).collect()(0).getInt(0)
Take a look at the documentation: Spark ScalaDoc.
Also can df.collect()[0][0] -or- df.collect()[0]['sum(ext)']

icCube: multiple dimensions in MDX output

The documentation of icCube states:
However, a SELECT is not limited to two axes. We could have columns,
rows, pages, chapters, and sections. And you could still continue
beyond these by specifying a number for the axis.
Indeed, when I try using three dimensions on the demo Sales cube, it works:
select
{[paris], [london]} on 0,
{[2005], [2006]} on 1,
product.members on 2
from sales
However, when I try four dimensions:
select
{[paris], [london]} on 0,
{[2005], [2006]} on 1,
product.members on 2,
measures.members on 3
from sales
I get an error message: Unexpected number of axes (4) for the pivot table (expected:0..3)
What am I missing?
There is nothing wrong with using a 4 axes query. However, it is left up to the client your are using to be able to display it.
For example, Excel accepts 2D results, the icCube pivot table is able to display results up to (and including) 3 axes.
Hope that helps.

Overriding the legend title using user specified string instead of variable name

I have a below code using ggplot2() package. I am trying to plot between the variables - 'Company Advertising' and 'Brand Revenue' of my data frame 'htmltable' , when the another variable 'Industry' is 'Luxury'; using ggplot() function. I am using another variable of my data frame 'Brand Value' as colour variable.
p<- ggplot(htmltable[htmltable$Industry='Luxury',],aes(x='CompanyAdvertising',y='BrandRevenue')
q <- p+geom_point(aes(color='BrandValue',size='BrandValue') + geom_text(label='Brand')
r <- q+xlab("Company Advertisiment in Billions")+ylab("Brand Revenue in Billions") +ggtitle("Luxury")
r+theme(plot.title=element_text(size=10,face='bold'),legend.key=element_rect(fill='light blue'))
Here, I want to change my legend title from "BrandValue" to "BrandValue in Billions". Please suggest.
I tried using labs parameter in the below statement. But it is resulting in 2 legends.
r <- q+xlab("Company Advertisiment in Billions")+ylab("Brand Revenue in Billions") +ggtitle("Luxury")+labs(colour="BrandValue in Billions")
Have you tried this ?
+labs(colour="BrandValue in Billions",
size="BrandValue in Billions")

Any way to give names to each of a set of successive integers?

I have an int called setupStage. This is simply a value I increment at the completion of each stage, so I can say, if (setupStage == 2), and I know that I am at the third stage (it defaults to 0).
Is there a way I can refer to these numbers in a better way? For example:
if (setupStage == stageEnterName)
Instead of having to refer to its actual raw int value.
It may be a misconception, but does what I am trying to achieve have anything to do with defining macros?
Yes!
Try this:
typedef enum {
MyType0,
MyType1,
MyType2,
MyType3
} MyType;
This is the same thing as this:
typedef enum {
MyType0 = 0,
MyType1,
MyType2,
MyType3
} MyType;
The values default to 0 at the first slot and then increment by 1 automatically. Note that the token names (MyTypeX) are arbitrary string values you set.
In this case they go from 0 to 3. Then you can say something like this:
if (setupStage == MyType3)
Which is identical to
if (setupStage == 3)
It sounds to me like you do want a macro like solution, and fortunately one exists.
STAGE_ONE = 0
STAGE_TWO = 1
STAGE_THREE = 2
# ...
if setupStage == STAGE_THREE:
will work.