iccube: how to define hierarchy dimension with intermediate table - olap

I am newbie, and can't find how to define dimension for such structure:
invoices:
--------
id
id_company
date
invoices_data:
-------------
id
id_invoice
id_product
amount
price
companies:
----------
id
caption
How to define companies dimension and link it to invoices_data table?

If possible I'd change the table structure. Note, it's possible to create an iccube table from an SQL statement.
I'd start by creating a few dimensions :
Company -> using 'companies' ; Multi-Levels just one level with id &
caption.
Date -> Use the Time (Wizard); add a start/end matching the data
you've.
Product -> using 'invoices_data' : Multi-Levels just one level with
id_product for both key & name
If possible I'd add the date to the 'invoice_data', SQL join. If no you can create a Many-2-Many table (advanced) that will do the join for you. More info here, I would not go for m2m unless really needed as it's an advanced features (read the link carefully).
Create a Cube, add 'Facts' with table 'invoice data'. Click on the last button 'Wizard' this will link all dimensions automatically. Eventually add your measures (amount & price).
And that should be it.
hope it helps

Related

How to add Data to table and Its sub-table simultaneously in MS Access through VBA?

I am very new to MS Access and I don't even know how should I start to approach for the solution.
I have a Table 1, that contains Project No., Part No. and Quantity of parts.
Now I want to transfer this data on button click to two different tables.
Table Order and Table Parts.
Table parts is a sub table of Table Orders
When we add project Number to table Orders, then we get auto-generated ID then based on that Unique ID, Table Parts is linked to it.
As we get ID from Table Orders, we need to create entry into table Parts with that ID that will contain Part Number and Quantity.
Can you please help me this?
I tried creating an append query but its just adding Project to Table Orders, not doing anything with Part No. and Quantity.

Go to different main table from same field AX 2012

I have a InvoiceAccount field in table. And another field in this table is PackingSlipAXType. If PackingSlipAXType is Sales, InvoiceAccount field value is customer account. If type is PurchReturn, InvoiceAccount field value is vendor account.
When value is customer account, when right click and go to main table i want to go Customer
and
When value is vendor account, when right click and go to main table i want to go vendor.
How can i do this in same field?
There are two primary ways. One is code and the other is using native MorphX and Conditional Table Relations. Code gives you more flexibility, but conditional table relations are simpler and "just work".
Conditional Table Relations
Using conditional table relations. I created a new table and AccountNum would represent a customer or vendor account, and the base enum SalesPurch is used to indicate if it is a Customer Account (Sales) or a Vendor Account (Purch). Similar to your setup.
See conditional table relations - https://learn.microsoft.com/en-us/dynamicsax-2012/developer/conditional-table-relations
See here for more info too.
Custom JumpRef & Lookup
You will likely want both a jumpRef and a lookup to both go to the correct main table and lookup the correct values.. This is code, but you have all the flexibility in the world...but may not need it.
Jumpref - https://community.dynamics.com/365/financeandoperations/b/faisalfareedaxlibrary/posts/ax-2012-how-to-use-jumpref-method
Lookup - https://learn.microsoft.com/en-us/dynamicsax-2012/developer/how-to-add-a-lookup-form-to-a-control
Jumpref example at \Data Dictionary\Tables\TmpCostAllocationBase_RU\Methods\jumpRefAgreement
Lookup example at \Data Dictionary\Tables\TmpCostAllocationBase_RU\Methods\lookupAgreement

Report with four tables for each account

I am struggling in the creation of a report including four tables.
Those tables should be the same for each account. I use just one dataset. When I run the report, the data is good, but tables listing appears wrong.
First all BALANCE DETAIL tables for all accounts selected are listed, then all DEBIT TRANSACTION tables for all accounts selected are listed etc.
For each account the page should show up just like this
Please give me an easy-to-understand answer since I am really a beginner in this sector.
It might be easier to this with 5 separate datasets, but I think you can do it with just on also.
Create on 'main' table on the dataset. use 4 detail rows, 1 column
Group it on accountnumber
In each detail of the main table, insert a new table with the same dataset.
Group those sub-tables also on accountnumber
Add a filter to the subtables. set the subtable accountnumber equal to the outer table account number (you can use the expression builder, but it should read something like this: row['ponum'] equals row._outer["ponum"] )
Good luck!

How do I create a running count of outcomes sequentially by date and unique to a specific person/ID?

I have a list of unique customers who have made transactions over a year (Jan – Dec). They have bought products using 3 different methods (card, cash, check). My goal is to build a multi-classification model to predict the method pf payment.
To do this I am engineering some Recency and Frequency features into my training data, but am having trouble with the following frequency count because the only way I know how to do it is in Excel using the Countifs and SUMIFs functions, which are inhibitingly slow. If someone can help and/or suggest another solution, it would be very much appreciated:
So I have a data set with 3 columns (Customer ID, Purchase Date, and Payment Type) that is sorted by Purchase Date then Customer ID. How do I then get a prior frequency count of payment type by date that does not include the count of the current row transaction or any future transactions that are > the Purchase Date. So basically I want to do a running count of each payment option, based on a unique Customer ID, and a date range that is < purchase date of that training row. In my head I see it as “crawling” backwards through the transactions and counting. Simplified screenshot of data frame is below with the 3 prior count columns I am looking to generate programmatically.
Screenshot
This gives you the answer as a list of CustomerID, PurchaseDate, PaymentMethod and prior counts
SELECT CustomerID, PurchaseDate, PaymentMethod,
(
select count(CustomerID) from History T
where
T.CustomerID=History.CustomerID
and T.PaymentMethod=History.PaymentMethod
and T.PurchaseDate<History.PurchaseDate
)
AS PriorCount
FROM History;
You can save this query and use it as the source for a crosstab query to get the columnar format you want
Some notes:
I assumed "History" as the source table name - you can change the query above to use the correct source
To use this as a query, open a new query in design view. Close the window that asks what tables the query is to be built on. Open the SQL view of the query design - like design view, but it shows the SQL instead of the normal design interface. Copy the above into the SQL view.
You should now be able to switch to datasheet view and see the results
When the query is working to your satisfaction, save it with any appropriate name
Open a new query in design view
When you get the list of tables to include, switch to the list of queries and include the query you just saved
Change the query type to crosstab and update the query as needed to select rows, columns and values - look up "access crosstab queries" if you need more help.
Another tip to see what is happening here:
You can take the subquery - the parts inside the () above - and make
just that statement into it's own query, excluding the opening and closing (). Then you can look at it's design view to see what it does
Save it with an appropriate name and put it into the query above in place of the statement in () - then you can look at the design view.
Sometimes it's easier to visualize and learn from 2 queries strung together this way than to work with sub queries.

Missing values in google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910

I am working with the practice repository in preparation for doing upcoming work with a large enterprise client using BQ. The repository link is: google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910
I have 3 questions to ask in relation to the sample repository & a query that was run (please see the bottom of the link for the query that motivated the question:
1) What is the difference between customDimensions.index, customDimensions.value and hits.customDimensions.index, hits.customDimensions.value?
2) If a single hit has multiple custom dimensions/metrics how is that returned/queried? I only see single dimensions matching at the hit level in the sample data.
3) There are no custom metric values passed in the example data, what will those values look like?
Here is the query that motivated the previous 3 questions:
SELECT hits.page.pagePath AS urls,
hits.time,
customDimensions.index,
customDimensions.value,
hits.customMetrics.index,
hits.customMetrics.value,
trafficSource.medium,
hits.customVariables.index,
hits.customVariables.customVarName,
hits.customVariables.customVarValue
FROM [google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910]
Every record in that table represents one Google Analytics Session. Big Query has this concept of nested fields and that's how individual hits are defined. They are nested into the hits record.
Answering your questions:
1) customDimensions.index and customDimensions.value are the index and value for user or session scoped custom dimensions. hits.customDimensions.index and hits.customDimensions.value re custom Dimensions set at hit scope level. The scope is defined when you create the custom Dimension through GA interface. indexes are integers from 1 to 20 (as defined in the Admin section) and value is the string passed as the value for that custom Dimension. More info about Custom Dimensions/Metrics
2) Both rows and rows.customDimensions are REPEATED RECORDS in Big Query. So in essence every row in that BQ table looks like this:
|- date
|- (....)
+- hits
|- time
+- customDimensions
|- index
|- value
But when you query the data this should be FLATTEN by default. Because it's flatten if a single hit has multiple custom dimensions and metrics it should show multiple rows, one for each.
3) Should be the same as customDimensions but the values are INTEGER instead of STRINGS.
For a simpler and more educational dataset I suggest that you create a brand new BQ table and load the data provided on this developer document page.
PS: Tell my good friends at Cardinal Path that Eduardo said Hello!

Resources