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.
Related
I would like to check if it's possible to plot more than one time-dimensions in a Google Data Studio chart, preferably a time series (line) chart. I'm having a lot of trouble to represent different information in the same chart through Google Data Studio.
I want to represent a sales cycle, that has 8 stages, meaning that most of them does not occur in the same day. All of them are related to one client/user. I've treated the data so I have this information separated, as I'm able to use it and create different and separated graphs - my intention, although, is to create one common graph with the time dimension not necessarily related to the other DateTime metrics.
Data set (Google Sheets):
Client ID (string)
Sign in at (date)
Commercial Approval at (date)
Commercial Approved (string)
Contract signed at (date)
Contract signed (string)
A
03/12/2021
05/12/2021
A
06/12/2021
A
B
03/12/2021
C
04/12/2021
05/12/2021
C
07/12/2021
C
D
05/12/2021
06/12/2021
D
E
06/12/2021
06/12/2021
E
The result I want to achieve (hand-made, on the PowerPoint):
Google Data Studio result I'm achieving:
Google Data Studio makes me choose one of the Date dimensions as the dimension. For example, if I chose the Signed at as a dimension and choose the period as between (including) 04/12/2021 and 06/12/2021, then Google Data Studio will group the Clients by Signed at, and overlook the activities by those that Signed at 03/12/2021.
You should try linking the two sources directly through the date's, and not choose any other dimension, only as metrics! This worked for me, but unfortunately I can't replicate it for another project.
It is worth a try anyway.
Looks like this:
enter image description here
I have imported my GA4 data into Google Data Studio and am trying to see how many giftcards have been sold by their value.
The item revenue metric in GA4 is equal to the giftcard value (i.e. revenue = $200 therefore $200 giftcard was sold).
I want to breakdown sales by giftcard value like so:
Giftcard (revenue)
Count
$200
4
$250
3
$300
6
To do this, I need to set a copy of item revenue as a dimension rather than a metric.
In Google Data Studio, I can create a calculated field with the following formula that should convert the item revenue into text:
CAST(Item Revenue AS TEXT)
The problem I'm having is that while the formula sets the field type as text, it is still regarded by GDS as a metric and can't be used as a dimension.
Even when I try to add text, GDS still recognises the field as a number:
CONCAT(CAST(Item Revenue AS TEXT), " giftcard")
To use a metric as a dimension you can make a combination of data. When defining the graphic element (table, for example) and the respective data source, just create a data combination, but do not combine the data with any other source and just define the combination with the initial data itself. So you will have the same data structure only through a combined structure.
When making a combination of data, data studio recognizes all calculated fields (metrics) as dimensions. Thus, it is possible to make the conversion.
I have a dataset including 3 columns :
ID transac (The unique ID of the transaction - Dimension)
Source (The source of the transaction - Dimension)
Amount € (The amount of the transaction - Stat)
screenshot of my dataset
To Count the number of transactions (for one or more sources), i use COUNT_DISTINCT function
I want to make the sum of the transactions amounts (for one or more sources). But i don't want to additionate the amounts of the transactions with the same ID !
Is there a way to do this calcul with a DataStudio function ?
Thanks for your answers. :-)
EDIT : I saw that we could do this type of calculation via SQL here and I would like to do this in DataStudio (so that I don't have to pre-calculate the amounts per source.)
IMO, your dataset contains wrong data. Each value should be relative only to that line, but this is not the case: if the total is =20, each line should describe the participation of that line to the total. With 4 sources, each line should be =5 or something else that sums 20.
To solve it in DataStudio, you need something like CALCULATE function in PowerBI, but currently DataStudio doesn't support this feature.
But there are some options to consider to repair your data:
If you're sure there are always 4 sources, just create a new calculated field with the expression Amount/4 and SUM it. It is not an elegant solution, but it works.
If your data source is Google Sheets, you can easily repair the data using formulas, like in this example:
Link to spreadsheet
For this spreadsheet, I used this formula in adjusted_amount column: =C2/COUNTIF(A:A,A2). With this column in DataStudio, just use the usual SUM aggregation function to summarize it correctly.
I'm working on a SSAS cube to allow user to analyze some sales.
So, I created a fact table to record all sales and few dimensions to browse inside data (category / location & store, etc...).
This is a example of the fact table output (from SQL Server Management Studio) :
When I browse my cube, I can review all sales including date, quantity, etc.
However, when I add some fields like the "unit price" or the "unit cost", it returns me a strange result probably due to an aggregate behavior.
It seems it return the sum of all matching rows (aggregateFunction property).
How to simply display the unit price of a sale without apply any calculation to the unit price column. The None value for the AttributeFunction display BLANK/NULL.
If your unitCost and unitPrice are the same for each product (I mean unitCost can be only 77.6 for product_id = 2), you can just use average (or even emulate average by SUM/COUNT) - but only for product dimension on axis!
Another dimensions will show real average values.
Maybe it's better to use this 'static' fields like attribute properties in 'Product' dimension? But you still need to add some logic to choose one value for several (or all) product members selected.
Is there a way to duplicate a formula with a circular reference from a Excel file into SQL Server? My client uses a excel file to calculate a Selling Price. The Selling Price field is (costs/1-Projected Margin)) = 6.5224 (1-.6) = 16.3060. One of the numbers that goes into the costs is commission which is defined as SellingPrice times a commission rate.
Costs = 6.5224
Projected Margin = 60%
Commissions = 16.3060(Selling Price) * .10(Commission Rate) = 1.6306 (which is part of the 6.5224)
They get around the circular reference issue in Excel because Excel allows them to check a Enable Iterative Calculation option and stops the iterations after 100 times.
Is this possible using SQL Server 2005?
Thanks
Don
This is a business problem, not an IT one, so it follows that you need a business solution, not an IT one. It doesn't sound like you're working for a particularly astute customer. Essentially, you're feeding the commission back into the costs and recalculating commission 100 times. So the salesman is earning commission based on their commission?!? Seriously? :-)
I would try persuading them to calculate costs and commissions separately. In professional organisations with good accounting practices were I've worked before these costs are often broken down into operating and non-operating or raw materials costs, which should improve their understanding of their business. To report total costs later on, add commission and raw materials costs. No circular loops and good accounting reports.
At banks where I've worked these costs are often called things like Cost (no commissions or fees), Net Cost (Cost + Commission) and then bizzarely Net Net Cost (Cost + Commission + Fees). Depending on the business model, cost breakdowns can get quite interesting.
Here are 2 sensible options you might suggest for them to calculate the selling price.
Option 1: If you're going to calculate margin to exclude commission then
Price before commission = Cost + (Cost * (1 - Projected Margin))
Selling price = Price before commission + (Price before commision * Commission)
Option 2: If your client insists on calculating margin to include commission (which it sounds like they might want to do) then
Cost price = Cost + (Cost * Commission)
Profit per Unit or Contribution per Unit = Cost price * (1-Projected Margin)
Selling Price = Cost Price + Profit per Unit
This is sensible in accounting terms and a doddle to implement with SQL or any other software tool. It also means your customer has a way of analysing their sales to highlight per unit costs and per unit profits when the projected margin is different per product. This invariably happens as the business grows.
Don't blindly accept calculations from spreadsheets. Think them through and don't be afraid to ask your customer what they're trying to achieve. All too often broken business processes make it as far as the IT department before being called into question. Don't be afraid of doing a good job and that sometimes means challenging customer requests when they don't make sense.
Good luck!
No, it is not possible
mysql> select 2+a as a;
ERROR 1054 (42S22): Unknown column 'a' in 'field list'
sql expressions can only refer to expressions that already exist.
You can not even write
mysql> select 2 as a, 2+a as b;
ERROR 1054 (42S22): Unknown column 'a' in 'field list'
The way to look at databases is as transactional engines that take data from one state into another state in one step (with combination of operators that operate not only on scalar values, but also on sets).
Whilst I agree with #Sir Wobin's answer, if you do want to write some recursive code, you may be able to do it by abusing Recursive Common Table Expressions:
with RecurseCalc as (
select CAST(1.5 as float) as Value,1 as Iter
union all
select 2 * Value,1+Iter from RecurseCalc where Iter < 100
), FinalResult as (
select top 1 Value from RecurseCalc order by Iter desc
)
select * from FinalResult option (maxrecursion 100)