TM1 Rules - different time dimensions in source and target cube - cognos-tm1

I have two cubes (source and target), but each with different time dimension.
Dimension Date of Record used in the source cube has following structure:
ALL *(this is the top element)*
- 2013
-- 2013 Q1
--- 2013 01
---- 01.01.2013 (data format is "DD.MM.YYYY")
Dimension Months (without any top element) used in the target cube is:
-2013
-- 01 2013 (data format is "MM YYYY")
For simplicity lets assume both cubes have only one more dimension - Measures. How to write a feeder to the source cube and rule to the target cube so that the data in both cubes are the same? Thank you!

I'm making an assumption that the measure is "units"... change it to what you like... also, Im naming the DoR cube as "Source", the "months" cube is named "Dest"...
In the 'Dest' cube rule file:
## Rule
['Units'] = N: DB('Source', SUBST(!Months, 4,4)|' '|SUBST(!Months, 1,2), 'Units');
In the 'Source' cube rule file:
## Feeder
['Units'] => DB('Dest', SUBST(!Date of Record, 6, 2)|' '|SUBST(!Date of Record, 1, 4), 'Units');
That said, if this number will not be updated frequently (i.e. less than once a day), I'd recommend using TurboIntegrator to map the data.

Related

Merging yearly .gdb geodatabases

I'm working with a database of land parcels and their corresponding crops per year (source)
My end goal is to create a predictive model for crop type, given land parcel. For example, if in the past 4 years a farmer grew soy, soy, corn and corn, what is the likely crop he'll be growing in 5th year.
There are 8 individual .gdb databases for years 2009 to 2016, but the schemas are the same; most importantly, land parcel geometry (polygon) and type of crop.
Ideally I'd want to work with one (time series) database where I have one row per parcel geometry, and one column per year (to record crop type for that year).
What is the best way to achieve this?
A lot of polygons 'repeat' across the years but with very slight variations in borders. So I guess any two polygons that overlap more than a given threshold should be given the same unque id. Samples:
2016 (green) and 2009 (red)
Only 2009 (red)
As you say .gdb, I assume you'd like to use or stick to ArcGIS?
In any case, a very basic approach to get you going (if getting you going is what you need): join the feature's tables.
If there is any sort of unique ID that is consistent throughout all GDBs, join them on this attribute.
(if not, there should also be a tool for a spatial join with a threshold to get the same result, as you suggested)
You can choose which colums to include in the joned table, and you can export the joined tables to a new GDB. Correct me, but I think this might be sufficent for your needs (I just brainstormed here).
If not, there are lots and lots of options using gdal/ogr, python, R, postgis, ... maybe you can list your preferrences in software?
Here are the steps I took:
Step 1. Convert gdb files to shape file, this is because apparently gdb is not an open source format and limited in tool support
ogr2ogr -f "ESRI Shapefile" 2009.shp 2009.gdb
ogr2ogr -f "ESRI Shapefile" 2010.shp 2010.gdb
.... same for other years ....
File names denote the dataset corresponding to that year.
Step 2. Import shape files into PostGIS
shp2pgsql -I -s 28992 2009.shp 2009 | psql -U postgres -d crops
.... same for other years ....
28992 is the SRID that I found with the help of this website.
Step 3. Add a foreign key column in 2010 table which stores the polygon id from 2009. Let's call it global_geo_id. If it's set for a polygon in 2010 it means it's the 'same' polygon from 2009.
Step 4. Do a spacial join between years in PostGIS
update "2010"
set global_geo_id = "2009".global_geo_id
from "2009" where
ST_Intersects("2009".geom,"2010".geom) and
(st_area(st_intersection("2009".geom,"2010".geom))/("2009".shape_area)) > 0.8
0.8 is a similarity threshold; the higher you set the more conservative the matching will be.
Step 5. Repeat steps 3, 4 for other years.

Using nested iif statements to subtract two columns of data

Working in Visual Studio 2012 to create a SSRS Business Intelligence Services Report.
Trying to do something like below where based on the value of one column, subtract the value of another column.
=iif(Fields!ACADEMIC_YEAR.Value=Parameters!ACADEMIC_YEAR.Value, Fields!TotalProspects_Dom.Value-iif(Fields!ACADEMIC_YEAR.Value=Parameters!ACADEMIC_YEAR.Value-1,Fields!TotalProspects_Dom.Value, 0),0)
Basically my table looks like:
essentially the table for the report is two rows, the current academic year and the previous academic year and I have to compare the two. Each row is made of columns representing the data for domestic and international data for a larger group.
I think you just need to have separate IIFs to determine the year.
= SUM(IIF(Fields!ACADEMIC_YEAR.Value = Parameters!ACADEMIC_YEAR.Value, Fields!TotalProspects_Dom.Value, 0)
- SUM(IIF(Fields!ACADEMIC_YEAR.Value = Parameters!ACADEMIC_YEAR.Value - 1, Fields!TotalProspects_Dom.Value, 0)

TM1 Rules - Linking multiple source cubes into one target cube

I have two (so far) source cubes and their respective dimensions:
EXPENSE: Date1, Date2, Supplier, Cost/Profit Center, Project, Type of Payment, Measures.
INCOME: Date1, Date2, Subcontractor, Customer, Cost/Profit Center, Project, Type of Payment, Measures.
I want to use the above mentioned cubes as a source for a third cube:
FINANCE: Date1, Cost/Profit Center, Project, Type of Payment, Measures.
The dimension Cost/Profit Center is used is each of these cubes and has following structure:
TOTAL
--EXPENSE
---10000 - Consulting
----11000 - Personal Expense
-----11100 - Sallary
------11101 - Gross Salary*
------11102 - Bonus*
...
--INCOME
---2000 - Services
----2100 - Projects
-----2110 - Support
------2111 - Support for ABC*
------2112 - Support for XYZ*
...
(*) Leaf elements
The goal is to load data from EXPENSE cube into FINANCE cube under Expense, and from INCOME cube to FINANCE cube under Income.
How do I define the rule without manually linking the corresponding leaf level members? I am looking for something like
['TOTAL':'Expense'] = N:DB(... data from Expense cube)
['TOTAL':'Income'] = N:DB(... data from Income cube)
So far I came up only with one solution which works although I am quite sure it is not the right approach:
[] = N: DB('Expense', '...) + DB('Income', '...)
Thanks a lot!
Using DB is of course required for any link between two cubes. Having said that, depending on your version of TM1, if performance modeller is available, creating graphical links is probably the easiest way to get the job done. It creates the rules in the respective cubes rule files so it is also a good learning tool.
To the essence of your question, as a high level view, let's assume that TM1 calculates the cube by running through its cells. Each cell is defined by members for all dimensions specified. When you rule something, the !Date1 variable (i.e. ! in front of the Date1 dimension name) gives you the member for the Date1 dimension of the current cell. Therefore, given that your Cost/Profit Centre dimension is the same, shared across cubes (not optimal and it should probably be Account) you can map one leaf element to the other (!Account).
For dimensions that you have in the source cube, but not in the target, you have to create a total element to use in the DB.
Finally, whatever rule you create to pull data in your Finance cube, you also have to create a feeder in your respective source cube.

MS Analysis Cube - one-to-many joins

I am building an OLAP cube in MS SQL Server BI Studio. I have two main tables that contain my measures and dimensions.
One table contains
Date | Keywords | Measure1
where date-keyword is the composite key.
One table contains looks like
Date | Keyword | Product | Measure2 | Measure3
where date-keyword-product is the composite key.
My problem is that there can be a one-to-many relationship between date-keyword's in the first table and date-keyword's in the second table (as the second table has data broken down by product).
I want to be able to make queries that look something like this when filtered for a given Keyword:
Measure1 Measure2 Measure3
============================================================
Tuesday, January 01 2013 23 19 18
============================================================
Bike 23
Car 23 16 13
Motorcycle 23
Caravan 23 2 4
Van 23 1 1
I've created dimensions for the Date and ProductType but I'm having problems creating the dimension for the Keywords. I can create a Keyword dimension that affects the measures from the second table but not the first.
Can anyone point me to any good tutorials for doing this sort of thing?
Turns out the first table had one row with all null values (a weird side effect of uploading an excel file straight into MS SQL Server db). Because the value that the cube was trying to apply the dimension to was null in this one row, the whole cube build and deploy failed with no useful error messages! Grr

MDX for calculated member with two measures over time hierarchy

I have a cube with two measures, say Measure A and Measure B. I need to create a single measure say C, from these two based on the business rule at any level of the hierarchy,
If A is not empty at the current level (has value for all children at that level), then just aggregate A. Else, aggregate A wherever it is present and aggregate B wherever A is not present and then sum both to make C.
It goes like this
Quarter Month A B
Q1 Apr 2 3
Q1 May 4
Q1 Jun 4
C should be 10 at Quarter level. Also, 2 for Apr, 4 for May and 4 for Jun [Month level]
I used the following MDX which works fine at Month level.
IIF(IsEmpty([Measures].[A]), [Measures].[B], [Measures].[A])
But, at quarter level it just gives me 2 instead of 10 which I now know why :)
Any pointers on building a MDX to make it work at any level
[Year - Semester - Quarter - Month] (Granularity is at Month level only)
will be helpful. Thanks :)
You can use this Mdx
Sum(
Descendants('current member on your time hierarchy', 'month level'),
CoalesceEmpty([Measures].[A], [Measures].[B])
)
CoalesceEmpty([Measures].[A], [Measures].[B]) is equivalent to IIf(IsEmpty([Measures].[A]), [Measures].[B], [Measures].[A])

Resources