How to group bar chart that using value list as dimension? - dimensions

I want to divide the chart into two parts, the first four need to be in one group called ETY and the rest belong to another group called PPY
my chart
My dimension : =ValueList('PE-UCC','PE-SDK','SM','Sales Dist','PP1','PP2','PP3')
My measure : if( valuelist('PE-UCC','PE-SDK','SM', 'Sales Dist','PP1','PP2','PP3')='PE-UCC' , sum(LLDPE)/(200000/12) ,
if( valuelist('PE-UCC','PE-SDK','SM', 'Sales Dist','PP1','PP2','PP3')='PE-SDK',Sum(HDPE)/(136000/12),
if(ValueList('PE-UCC','PE-SDK','SM', 'Sales Dist','PP1','PP2','PP3')='SM', Sum(SMI) / (340000/12),
if( ValueList( 'PE-UCC','PE-SDK','SM', 'Sales Dist','PP1','PP2','PP3')='Sales Dist', (Sum(PENI)+Sum(SULFINDO)+Sum(POlychem)+ Sum(ASAHI) +Sum( Mc ) +Sum(Ship))/38000,
if(ValueList('PE-UCC','PE-SDK','SM', 'Sales Dist','PP1','PP2','PP3')='PP1',Sum(PP1)/(Floor(MonthEnd(Max(DATE))) - Floor(MonthStart(Max(DATE))) + 1)/24/20,
if(ValueList('PE-UCC','PE-SDK','SM', 'Sales Dist','PP1','PP2','PP3')='PP2',Sum(PP2)/(Floor(MonthEnd(Max(DATE))) - Floor(MonthStart(Max(DATE))) + 1)/24/20,
if(ValueList('PE-UCC','PE-SDK','SM', 'Sales Dist','PP1','PP2','PP3')='PP3',Sum(PP3)/(Floor(MonthEnd(Max(DATE))) - Floor(MonthStart(Max(DATE))) + 1)/24/20)))))))

You can use group dimension, for it you must create a new dimension with grouped values. In this video, you can view as developed it.
Dimensions - Grouping
Qlik Sense Desktop – Drill-down Group Dimension
When you have created the dimension, only add it to the bar chart and add your measure.

Related

qlik sense - KPI to table measure issue using rank

I have the following in a kpi
Sum({$<RankNo =
{"=rank(Only({$<OrderWeekFlag = {1}, [DeliveryDate] =
{'>=$(=vMinDeliveryWeek)'}>
+
<OrderWeekFlag = {1}>}RankNo))
<=
$(=sum({$< [DeliveryDate]= {'>=$(=vMinDeliveryWeek)'} , OrderWeekFlag = {1} >}[HasOrder]))
"},OrderWeekFlag = {1} >}
[HasOrder])
I need to use this now in a table as a measure with the dimension 'Department', but the numbers are not working because of the rank within the expression. I have tried to use "aggr", "aggr with total" in different places within the expression with no joy.
 
I get different numbers when used in the table for each department, but when I click on an individual department (e.g 'Kitchen') it drills down to the correct number. please help / any ideas?

Where Clause using another Dimension Value

I'm trying to create a Calculated Member in my cube with where clause but couldn't figure how to achieve the proper result.
I created a calculated member "Outlook" using the below code to display only Forecast values.
CREATE MEMBER CURRENTCUBE.[Measures].[Outlook]
AS SUM(([Source Profile].[Source Profile Hierarchy].CurrentMember,
[Source Profile].[Profile Level01].&[Outlook]),
[Measures].[USD Amount]),
FORMAT_STRING = "#,##0;(#,##0)",
VISIBLE = 1 , DISPLAY_FOLDER = 'USD' , ASSOCIATED_MEASURE_GROUP = 'CARS';
Cube Result
Now I would like to filter the results dynamically based on another hidden dimension "Current_Month". This dimension always has current financial period value and it's corresponding outlook profile
Year_Month Outlook_Profile
2015010 10 + 2
Expected result should be "Outlook" measure showing value based on Current_Month dimension, which is '10 + 2' and rest of them should be 0
Expected result
Just to explain the requirement in SQL terms, I would like to achieve the below in MDX
Where Fact.Source_Profile=Dimension.Source_Profile
instead of
Where Fact.Source_Profile='10 + 2'
I'm not sure how to achieve this in Where Clause or by another means. I could see examples of hard coding values, like year.&[2015] but haven't seen one using dynamic values.
I found a solution myself and thought of sharing the same. Used StrToMember function to pass hidden dimension's member as a variable here.
CREATE MEMBER CURRENTCUBE.[Measures].[Outlook]
AS (
Sum
(
(
[Source Profile].[Source Profile Hierarchy].CurrentMember,
strtomember("[Source Profile].[Source Name].&[" + [Outlook Profile].[Outlook Profile].&[1].Member_Caption + "]")
)
,[Measures].[USD Amount]
)
),
FORMAT_STRING = "#,##0;(#,##0)",
VISIBLE = 1 , DISPLAY_FOLDER = 'USD' , ASSOCIATED_MEASURE_GROUP = 'CARS' ;

SSAS: How can I create calculated member using multiple conditions on different hierarchy

I have problem with my SSAS Cube.
I have to implement basic calculation to my Cube:
sum(Ammount) where BOOK = "Assets" and CD_PRODUCT_L4 <> "LoanLoss"
My dimmension is in image below:
Dimension attributes: BOOK, CD_PRODUCT_L4, CD_PRODUCT_L5, ..
Hierarchy PROD: CD_PRODUCT_L4 - CD_PRODUCT_L5
CREATE MEMBER CURRENTCUBE.[Measures].[Principal Loans]
AS (
except(
[PLV PRH HDIM CB].[BOOK].&[ASSETS_ON],
[PLV PRH HDIM CB].[COD PRODUCT L4].&[51L4]
),
[Measures].[EOM PRINCIPAL_a])
The biggest thing is that conditions are not from same hierarchy level so I can't use except and I know no other way to implement this particular condition set
Please HELP, Thank you
Product dimmension model
I manage to solve the issue by adding hierarchy to my dimension which allowed me to use except as I wanted before but I'am not satisfied with this solution because it looks more like workaround then solution
CREATE MEMBER CURRENTCUBE.[Measures].[Principal Loans] AS
sum((except([PLV PRH HDIM CB].[Hierarchy BOOK].[BOOK].&[ASSETS_ON].children,[PLV PRH HDIM CB].[Hierarchy BOOK].[COD PRODUCT L4].&[51L4]),[Measures].[EOM PRINCIPAL_a]))
This is probably the closest example that I can provide you to what you need.
This, code below, is just one of about 50 or so Measures we have defined, ranging from Counts, Averages, Sums, Percentages, etc. We take a single DW value and perform at least 2 seperation calculations, most have 4 or more different calculations, from that one field.
CREATE MEMBER CURRENTCUBE.[Measures].[Count Previous Difference]
AS Case
// Test for current coordinate being on (All) member.
When [Date].[YearMonth].CurrentMember.Level Is [Date].[YearMonth].[(All)]
Then "NA"
Else
( [Date].[YearMonth].CurrentMember, [Measures].[Gross Count] )
-
( ParallelPeriod (
[Date].[YearMonth].CurrentMember.Level,
1,
[Date].[YearMonth].CurrentMember
),
[Measures].[Gross Count]
)
End,
FORMAT_STRING = "#,##0.00;-#,##0.00",
NON_EMPTY_BEHAVIOR = { [Gross Count] },
VISIBLE = 0 , ASSOCIATED_MEASURE_GROUP = 'Some Summary';
Keep in mind we also use our DW & Cube with SharePoint and SSRS reports.

WHERE clause in calculated member

I am facing some problem to calculate values from comparing dimension's value. I have 3 dimensions (Datatype, Customer, Product) and one measure (GrossSales).
What would be the MDX query if I want GrossSales for ProductID = 1,2,3 and Dataype = 4,5,6?
Here Datatype has relationship with GrossSales, Customer has relationship with GrossSales and Product has relationship with Customer.
I am trying this but doesn't work
CREATE MEMBER CURRENTCUBE.[Measures].Forecast_Gross_Sales AS
(
SELECT NON Empty [Measures].[Gross Sale]
FROM [Measures]
WHERE (
[Data Type].[ID].[ID] = 4
AND [Chain].[Customer ID] = [Measures].[Customer ID]
)
), VISIBLE = 1
, DISPLAY_FOLDER = 'Forecast'
, ASSOCIATED_MEASURE_GROUP = 'Data Types';
It looks like you are just getting started with MDX. There are some fundamental concepts that will help you get what you need. This comparison of SQL and MDX might be helpful. MDX uses the where clause as a slicer (to select certain dimension members) rather than a filter. You can't put member = somevalue in the where clause. And you can't really use the where clause to define a relationship to some other table.
Instead, your where clause would be something more like
[Data Type].[ID].[ID].&[4]
Since I can't see your data model, I can't be sure, but I would guess that [Chain].[Customer ID] = [Measures].[Customer ID] is something that you want to define the the dimension usage of your cube rather than in the query.
Edit: Now that the question has been edited, it looks like you are creating a calculated member. in this case there is no select or where clause. It will look more like this:
CREATE MEMBER CURRENTCUBE.[Measures].Forecast_Gross_Sales AS
Aggregate([Data Type].[ID].[ID].&[4], [Measures].[Gross Sale])
, VISIBLE = 1
, DISPLAY_FOLDER = 'Forecast'
, ASSOCIATED_MEASURE_GROUP = 'Data Types';
The relationship from the measure group through the Customer dimension to the Chain dimension is something that should be defined in the dimension usage. This is called a Reference dimension relationship.

MDX - Drill down in a hierarchy to the last level having the member caption containing "#"

I have a UserHierarchy, and when the member caption of the current level contains a "#" in the name, is resembles a particular user type. The UserHierarchy, contains up to 5 levels.
I would like to display drilled down data, but only for these particular user types, hence only those captions which have "#". I would also want to aggregate the children's data.
Is there a simple way in MDX to accomplish this?
Example :
#User1 €2
---#User2 €6
---------User4 €9
---------User5 €4
---#User3 €2
---------User6 €4
---------User7 €4
I would like to display figures, for themselves and children like this. To understand, I included where the figures were obtained from :
#User1 €2
---#User2 €19 (Obtained from : €6 + €9 + €4)
---#User3 €10 (Obtained from : €2 + €4 + €4)
select [Measures].[Internet Sales Amount] on columns,
non empty(
distinct(
descendants({[Product].[Category].children}) *
{filter([Product].[Subcategory].members,
instr([Product].[Subcategory].currentmember.member_caption, 'T') = 1)
}
* descendants({[Product].[Product].children})
)
)
on rows from cube
Result with detailed info:
"Second result:
Here i have deleted the row:
* descendants({[Product].[Product].children})
I think that´s what you want since it shows the totals of the children.
You need to exchange the 'T' for your '#' then also the dimension names and what you want to show as a measure.