Aggregating by Day of Week in Mondrian - mondrian

I am trying to extend the Pentaho example of a simple TimeDimension to aggregate by Day Of Week
This is the example provided:
<Dimension name="Time" type="TimeDimension">
<Hierarchy hasAll="true" allMemberName="All Periods" primaryKey="dateid">
<Table name="datehierarchy"/>
<Level name="Year" column="year" uniqueMembers="true" levelType="TimeYears" type="Numeric"/>
<Level name="Quarter" column="quarter" uniqueMembers="false" levelType="TimeQuarters"/>
<Level name="Month" column="month" uniqueMembers="false" ordinalColumn="month" nameColumn="month_name" levelType="TimeMonths" type="Numeric"/>
<Level name="Week" column="week_in_month" uniqueMembers="false" levelType="TimeWeeks"/>
<Level name="Day" column="day_in_month" uniqueMembers="false" ordinalColumn="day_in_month" nameColumn="day_name" levelType="TimeDays" type="Numeric"/>
</Hierarchy>
</Dimension>
(Reference here)
My modified Dimension looks like this:
<Dimension name="Time" type="TimeDimension">
<Hierarchy hasAll="true" allMemberName="All Periods" primaryKey="date_id">
<Table name="dates"/>
<Level name="Year" column="year" uniqueMembers="true" levelType="TimeYears" type="Numeric"/>
<Level name="Month" column="month" uniqueMembers="false" ordinalColumn="month" nameColumn="month" levelType="TimeMonths" type="Numeric"/>
<Level name="Week" column="week" uniqueMembers="false" levelType="TimeWeeks"/>
<Level name="Day" column="day" uniqueMembers="true" ordinalColumn="day_in_week" nameColumn="day_of_week" levelType="TimeDays" type="Numeric"/>
</Hierarchy>
</Dimension>
I am running up against a challenge whereby Saiku (using as front end to the Mondrian Cube) insists that my Day column should always be based on the hierarchy of Year-Month-Week which is obviously fine for drill down but not if I just want aggregates by day (e.g. Average sales on a Monday versus a Tuesday). I've tried adding another dimension but no matter what I do I end up with N * day name records where N is the number of records I have (ideally I'd have 7 rows returned based on the relevant Measure)

Did you try separate dimension with single level?
<Dimension name="Time" type="TimeDimension">
<Hierarchy hasAll="true" allMemberName="All Periods" primaryKey="date_id">
<Table name="dates"/>
<Level name="Day" column="day" uniqueMembers="true" nameColumn="day_of_week" levelType="TimeDays" type="Numeric"/>
</Hierarchy>
</Dimension>
I think this could be solved with Mondrian4 and Saiku3, but currently I don't think there are other options.

Related

How to avoid scentific notation in Saiku Attribute

I define saiku(3.8) schema as below:
<?xml version="1.0" encoding="utf-8"?>
<Schema name="Zeus Offline Data" metamodelVersion='4.0'>
<PhysicalSchema>
<Table name="ZEUS_OFFLINE_DATA">
<Key>
<Column name='FB_ACCOUNT_ID'/>
</Key>
</Table>
</PhysicalSchema>
<Cube name="OfflineData">
<Dimensions>
<Dimension name="AdAccount" table="ZEUS_OFFLINE_DATA">
<Attributes>
<Attribute name="account_id" keyColumn="FB_ACCOUNT_ID" hasHierarchy="true"/>
</Attributes>
</Dimension>
<Dimension name="BM" table="ZEUS_OFFLINE_DATA">
<Attributes>
<Attribute name="bm_id" keyColumn="BM_ID" hasHierarchy="true"/>
</Attributes>
</Dimension>
</Dimensions>
<MeasureGroups>
<MeasureGroup name="Stats" table="ZEUS_OFFLINE_DATA">
<Measures>
<Measure name="clicks" column="CLICKS" aggregator="sum" formatString="#,###"/>
</Measures>
<DimensionLinks>
<FactLink dimension="AdAccount"/>
<FactLink dimension="BM"/>
</DimensionLinks>
</MeasureGroup>
</MeasureGroups>
It contains two dimension "bm_id" and "fb_account_id", and one measure "clicks".In database backend, bm_id and fb_account_id are int type. When I make query in Saiku, the result of bm_id and fb_account_id are shown in scientific notation mode, which I don't want.
Result:
bm_id clicks
1.71141391154125E14 1,091,234
Which I want:
171141391154125 1,091,234
I don't know which attribute should be changed for that, any help appreaciated
Thanks

Custom targets for widget Layout Updates in Magento 2

I would like help working out how to add a custom container as a 'Layout Update' for a widget..
Currently, I only have the 3 basic options to choose from (Main Content Area, Siderbar Main and Sidebar Additional), but I would like to be able to add widgets to containers that I've created through various default.xml files.
How would I go about doing that?
Thanks,
Luke
In widget.xml You create additional area.Under catalog module you can see that.
<widget id="new_products" class="Magento\Catalog\Block\Product\Widget\NewWidget" is_email_compatible="true"
placeholder_image="Magento_Catalog::images/product_widget_new.png" ttl="86400">
<label translate="true">Catalog New Products List</label>
<description translate="true">List of Products that are set as New</description>
<parameters>
<parameter name="display_type" xsi:type="select" required="true" visible="true">
<label translate="true">Display Type</label>
<description translate="true">All products - recently added products, New products - products marked as new</description>
<options>
<option name="default" value="all_products" selected="true">
<label translate="true">All products</label>
</option>
<option name="item" value="new_products">
<label translate="true">New products</label>
</option>
</options>
</parameter>
<parameter name="show_pager" xsi:type="select" visible="true"
source_model="Magento\Config\Model\Config\Source\Yesno">
<label translate="true">Display Page Control</label>
</parameter>
<parameter name="products_per_page" xsi:type="text" required="true" visible="true">
<label translate="true">Number of Products per Page</label>
<depends>
<parameter name="show_pager" value="1" />
</depends>
<value>5</value>
</parameter>
<parameter name="products_count" xsi:type="text" required="true" visible="true">
<label translate="true">Number of Products to Display</label>
<value>10</value>
</parameter>
<parameter name="template" xsi:type="select" required="true" visible="true">
<label translate="true">Template</label>
<options>
<option name="default" value="product/widget/new/content/new_grid.phtml" selected="true">
<label translate="true">New Products Grid Template</label>
</option>
<option name="list" value="product/widget/new/content/new_list.phtml">
<label translate="true">New Products List Template</label>
</option>
<option name="list_default"
value="product/widget/new/column/new_default_list.phtml">
<label translate="true">New Products Images and Names Template</label>
</option>
<option name="list_names"
value="product/widget/new/column/new_names_list.phtml">
<label translate="true">New Products Names Only Template</label>
</option>
<option name="list_images"
value="product/widget/new/column/new_images_list.phtml">
<label translate="true">New Products Images Only Template</label>
</option>
</options>
</parameter>
<parameter name="cache_lifetime" xsi:type="text" visible="true">
<label translate="true">Cache Lifetime (Seconds)</label>
<description translate="true">86400 by default, if not set. To refresh instantly, clear the Blocks HTML Output cache.</description>
</parameter>
</parameters>
<containers>
<container name="sidebar.main">
<template name="default" value="list_default" />
<template name="names_only" value="list_names" />
<template name="images_only" value="list_images" />
</container>
<container name="content">
<template name="grid" value="default" />
<template name="list" value="list" />
</container>
<container name="sidebar.additional">
<template name="default" value="list_default" />
<template name="names_only" value="list_names" />
<template name="images_only" value="list_images" />
</container>
</containers>
</widget>
Please go through the <containers> tag above code you will understand.There is a container tag

Anychart datetime on the y_axis

I am trying to show a trend of processes that run every day over time. Therefore I have a date which I call processing date, which I want to be shown on the X-Axis, and an end_time (date timestamp) since the end time can finish before or after midnight. Therefore I would like to be able to plot the data on the Y axis. I am using Oracle APEX v5, not sure which version of Anychart is running behind, maybe this is version related?
So far, I have not figured out a way for the values returned by my query to be plotted correctly when the values are dates. Is this possible? These are the settings of the y_axis, which when used do not show any data on the graph.
<y_axis >
<scale type="DateTime" mode="Normal" />
<title enabled="false" />
<labels enabled="true" position="Outside">
<font family="Tahoma" size="10" color="0x000000" />
<format>
<![CDATA[{%Value}]]>
</format>
</labels>
<major_grid enabled="False"/>
<minor_grid enabled="False"/>
</y_axis>
When I convert the dates to a number, they are plotted correctly, but so far I had no luck with trying to convert them back to a date using the settings/locale:
<settings>
<locale>
<date_time_format>
<format>%yyyy%MM%dd%HH%mm%ss</format>
</date_time_format>
</locale>
<animation enabled="false"/>
<no_data show_waiting_animation="False">
<label>
<text>#NO_DATA_MESSAGE#</text>
<font family="Verdana" bold="yes" size="10"/>
</label>
</no_data>
</settings>
I am using this to generate the test points with values:
select null as link, trunc (sysdate) as label, to_char((sysdate),'YYYYMMDDHH24MISS') as end_time from dual
union
select null as link, trunc (sysdate)-1 as label, to_char((sysdate)-1,'YYYYMMDDHH24MISS') as end_time from dual
order by label;
The Value of the point ends up being "2016%MM20%HH00%ss", I tried changing the upper/lower case of the formatting to no avail. From the output it looks like the %vars cannot be used concatenated, but if that is the case, then I cannot use values to convert the dates...
Maybe this is conceptually wrong, but so far I have not found a way to plot these correctly. I hope someone can shed some light on this.
Thank you in advance.
Edit:
I managed to do it ignoring the XML from Apex and creating my own datapoints (I will post the complete answer later), this is a sample of the XML:
<?xml version = "1.0" encoding="utf-8" standalone = "yes"?>
<anychart>
<settings>
<animation enabled="false" />
<no_data show_waiting_animation="False">
<label>
<text>No data found</text>
<font family="Verdana" bold="yes" size="10" />
</label>
</no_data>
<locale>
<date_time_format>
<format>
<![CDATA[%dd-%MM-%yyyy %HH:%mm]]>
</format>
</date_time_format>
</locale>
</settings>
<margin left="0" top="0" right="0" bottom="0" />
<charts>
<chart plot_type="CategorizedVertical" name="chart_52322125829114359521">
<chart_settings>
<title enabled="False" />
<chart_background>
<fill type="Solid" color="0xffffff" opacity="0" />
<border enabled="false" />
<corners type="Square" />
</chart_background>
<data_plot_background></data_plot_background>
<axes>
<y_axis>
<scale type="DateTime" mode="Normal" />
<title enabled="false" />
<labels enabled="true" position="Outside">
<font family="Tahoma" size="10" color="0x000000" />
<format>
<![CDATA[{%Value}{dateTimeFormat:%HH:%mm}]]>
</format>
</labels>
<major_grid enabled="True" interlaced="false">
<line color="Black" />
</major_grid>
<minor_grid enabled="True"></minor_grid>
</y_axis>
<x_axis>
<scale type="DateTime" mode="Normal" />
<title enabled="false" />
<labels enabled="true" position="Outside">
<font family="Tahoma" size="10" color="0x000000" />
<format>
<![CDATA[{%Value}{dateTimeFormat:%ddd %dd-%MM-%yyyy}]]>
</format>
</labels>
<major_grid enabled="True" interlaced="false">
<line color="Black" />
</major_grid>
<minor_grid enabled="True"></minor_grid>
</x_axis>
</axes>
<legend enabled="true" position="Right" align="Near" elements_layout="Vertical">
<title enabled="False"/>
<icon>
<marker enabled="true" />
</icon>
<font family="Tahoma" size="10" color="0x000000" />
</legend>
</chart_settings>
<data_plot_settings enable_3d_mode="false" default_series_type="Line">
<line_series>
<tooltip_settings enabled="true">
<format>
<![CDATA[{%SeriesName} {%Name} {%Value}{dateTimeFormat:%HH:%mm}]]>
</format>
<font family="Tahoma" size="10" color="0x000000" />
<position anchor="Center" valign="Top" halign="Center" padding="10" />
</tooltip_settings>
<label_settings enabled='&LABEL.' mode="Outside" multi_line_align="Center">
<format>
<![CDATA[{%Value}{dateTimeFormat:%HH:%mm}]]>
</format>
<background enabled="false" />
<font family="Tahoma" size="10" color="0x000000" />
</label_settings>
<line_style>
<line enabled="true" thickness="2" opacity="1" />
</line_style>
<marker_settings enabled="True" >
<marker type="HLine" />
</marker_settings>
</line_series>
</data_plot_settings>
<data>
<series name="AEG" type="Line">
<point name="01-03-2016 00:00" y="01-01-2001 23:35"></point>
<point name="02-03-2016 00:00" y="01-01-2001 23:16"></point>
<point name="03-03-2016 00:00" y="01-01-2001 23:20"></point>
<point name="04-03-2016 00:00" y="01-01-2001 23:32"></point>
<point name="07-03-2016 00:00" y="01-01-2001 23:28"></point>
<point name="08-03-2016 00:00" y="01-01-2001 23:24"></point>
<point name="09-03-2016 00:00" y="01-01-2001 23:14"></point>
<point name="10-03-2016 00:00" y="01-01-2001 23:30"></point>
<point name="11-03-2016 00:00" y="01-01-2001 23:54"></point>
<point name="14-03-2016 00:00" y="01-01-2001 23:52"></point>
<point name="15-03-2016 00:00" y="01-01-2001 23:27"></point>
<point name="16-03-2016 00:00" y="01-01-2001 23:51"></point>
<point name="17-03-2016 00:00" y="01-01-2001 23:34"></point>
<point name="18-03-2016 00:00" y="01-01-2001 23:32"></point>
<point name="21-03-2016 00:00" y="02-01-2001 00:02"></point>
</series>
</data>
</chart>
</charts>
</anychart>
A new question is, can you help me understand why the tooltip does not get the correct value on the %Name?
<![CDATA[{%SeriesName} {%Name} {%Value}{dateTimeFormat:%HH:%mm}]]>
In the tooltip I am getting the following text on the first point is AEG 01-01-1970 00:00 23:35 and I was expecting, based on the name 01-03-2016 00:00 23:35
Thanks!

Snowflake dimension with multiple levels mondrian

My tables structure is as follows
dim_question_tbl table with primary key dim_question_id_i(pk)
dim_grade_tbl -> dim_grade_id_i(pk), grade_name_c
dim_level_tbl -> dim_level_id_i(pk), level_name_c
dim_grade_question_tbl -> dim_grade_question_id_i(pk), dim_grade_id_i(fk), dim_level_id_i(fk)
Now i have to have the grade and level as the levels in dimension.
The cube written on the 'dim_question_tbl' table.
I have written the dimension as
<Dimension name="Grade" foreignKey="dim_question_id_i" highCardinality="false">
<Hierarchy hasAll="true" primaryKey="dim_question_id_i" primaryKeyTable="dim_grade_question_tbl">
<join leftKey="dim_grade_id_i" rightKey="dim_grade_id_i">
<table name="dim_grade_question_tbl" />
<join leftKey="dim_level_id_i" rightKey="dim_level_id_i">
<table name="dim_grade_tbl" />
<table name="dim_level_tbl" />
</join>
</join>
<Level name="EnterpriseID" column="dim_enterprise_id_i" table="dim_grade_tbl" uniqueMembers="true" visible="false"/>
<Level name="Grade" column="grade_name_c" table="dim_grade_tbl" uniqueMembers="true"/>
<Level name="Level" column="level_name_c" table="dim_level_tbl" uniqueMembers="true"/>
</Hierarchy>
</Dimension>
This does not working. The exception i am getting is '[Grade]' must have at least one level.
I have tried it with sql query also as
<Dimension name="Grade" foreignKey="dim_question_id_i" highCardinality="false">
<Hierarchy hasAll="true" primaryKey="dim_question_id_i" primaryKeyTable="dim_grade_question_tbl">
<Query name="test">
<SQL dialect="generic">
SELECT *
FROM dim_grade_question_tbl, dim_grade_tbl, dim_level_tbl
WHERE dim_grade_question_tbl.dim_grade_id_i = dim_grade_tbl.dim_grade_id_i
and dim_grade_question_tbl.dim_level_id_i = dim_level_tbl.dim_level_id_i
</SQL>
</Query>
<Level name="Grade" column="grade_name_c" table="dim_grade_tbl" uniqueMembers="true"/>
<Level name="Level" column="level_name_c" table="dim_level_tbl" uniqueMembers="true"/>
</Hierarchy>
</Dimension>
With the sql query also the same exception i am getting.
Could any one help me how can i get the multiple levels with the snowflake schema?

OLAP cube in schema workbench measures shows no data

Iv'e created a simple Schema in Jaspersoft OLAP designer. Now i want to publish my Cube in a view on jasperreport Server.
I managed to get this to work before with other Schemas but now i don't get any values out of my sum measures...
Can anyone see some Problem in here?
<Schema name="AbsatzView">
<Cube name="Budget" cache="true" enabled="true">
<Table name="vBudgetDetail" schema="dbo" alias="">
</Table>
<Dimension type="TimeDimension" foreignKey="ZeitID" name="GJahr">
<Hierarchy name="" hasAll="false" primaryKey="ID">
<Table name="vBudgetTimes" schema="dbo" alias="">
</Table>
<Level name="Gjahr" column="Gjahr" uniqueMembers="true" levelType="TimeYears">
</Level>
<Level name="Monat" column="Monat" uniqueMembers="false" levelType="TimeMonths">
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" foreignKey="VersionID" name="Aktiv Version">
<Hierarchy hasAll="false" primaryKey="VersionID">
<Table name="vBudgetVersionAktiv" schema="dbo" alias="">
</Table>
<Level name="Version" column="version" type="String" uniqueMembers="false" levelType="Regular">
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" foreignKey="VersionID" name="Vorherige Version">
<Hierarchy name="" hasAll="false" primaryKey="VersionID">
<Table name="vBudgetVersionV1" schema="dbo" alias="">
</Table>
<Level name="Version" column="version" type="String" uniqueMembers="false" levelType="Regular">
</Level>
</Hierarchy>
</Dimension>
<Measure name="Absatz Plan" column="PlanAbsatz" aggregator="sum" visible="true">
</Measure>
<Measure name="Umsatz Plan" column="PlanUmsatzLW" aggregator="sum" visible="true">
</Measure>
</Cube>
</Schema>
I know that this for example this mdx have to give me values in my measures but it's empty and i don't know why?
select {[Measures].[Absatz Plan]} ON COLUMNS,
{[GJahr].[2013], [GJahr].[2014], [GJahr].[2015]} ON ROWS
from [Budget]
If i use the same tables in SQL and asks exact for the same Thing i get correct values
SELECT b.Gjahr,SUM(a.PlanAbsatz) FROM vBudgetDetail a
INNER JOIN vBudgetTimes b ON b.ID = a.ZeitID
GROUP BY b.Gjahr
Try this query
select {[Measures].[Absatz Plan]} ON COLUMNS,
{[GJahr].&[2013], [GJahr].&[2014], [GJahr].&[2015]} ON ROWS
from [Budget]
Or this:
select {[Measures].[Absatz Plan]} ON COLUMNS,
{[GJahr].[GJahr].&[2013], [GJahr].[GJahr].&[2014], [GJahr].[GJahr].&[2015]} ON ROWS
from [Budget]

Resources