Using the same OrderByAttribute for two attributes in one dimension - sorting

In my SSAS cube I have a dimension with attributes A and B, and I want both to be displayed in the sort order specified by a third attribute C. If I specify C as the OrderByAttribute for A and reprocess the cube, then A is sorted correctly.
If I then specify C as the OrderByAttribute for B as well and reprocess the cube, then A continues to be sorted correctly but B does not. Values of B are displayed in an order that seems arbitrary. I have triple-checked that there is no difference in the way A and B are configured.
Is there some conceptual reason why two attributes in a single dimension cannot be both sorted by the same third attribute?

I have now located the problem but still looking for a solution.
As mentioned in the comments, the dsv has tables CM and DisplayOrder between which there are two relationships -- from CM.A to DisplayOrder.primarykey and from CM.B to DisplayOrder.primarykey. SSAS constructs the attribute A using the query:
select distinct CM.A, DisplayOrder.SortOrder
from
(<named query for CM>) as CM,
(<named query for DisplayOrder>) as DisplayOrder
where CM.A = DisplayOrder.primarykey
That is correct and works fine. But when SSAS constructs the attribute B, it uses the query:
select distinct CM.B, DisplayOrder.SortOrder
from
(<named query for CM>) as CM,
(<named query for DisplayOrder>) as DisplayOrder
where CM.A = DisplayOrder.primarykey
Note that the where clause links the two tables using A rather than for B.
So in summary, when the dsv has two tables with two relationships between them, the join in the queries generated by SSAS to implement the OrderByAttribute always use one of those relationships and ignores the other.
Any idea why, or if there is a property somewhere I may have missed?

Related

How to speed-up a spatial join in BigQuery?

I have a BigQuery table with point registers along a whole country, and I need to assign a "censal zone" to each one of them, which polygons are contained in another table. I've been trying to do so using a query like this one:
SELECT id_point, code_censal_zone
FROM `points_table`
JOIN `zones_table`
ON ST_CONTAINS(zone_polygon, point_geo)
The first table is quite large, so the query performes very inefficiently as it is comparing each possible pairs of (point, censal zone). However, both tables have a column identifier for the municipality in which they are in, so the question is, can rewrite my query in some way that ST_CONTAINS(*) is performed for each (point, censal zone) pair that belongs to the same municipality, hence not comparing all posible censal zones within the country for each point? Can I do this without having to read points_table multiple times?
SELECT id_point, code_censal_zone
FROM `points_table`
JOIN `zones_table`
ON 1.municipality = 2.municipality
AND ST_CONTAINS(zone_geo, point_geo)
I'm quite new to BigQuery so I don't really know if a query like this would actually do what I'am expecting, as I couldn't find anything in the documentation.
Thanks!
SELECT id_point, code_censal_zone
FROM `points_table`
JOIN `zones_table`
ON 1.municipality = 2.municipality
AND ST_CONTAINS(zone_geo, point_geo)

How to skip columns in “List from a range” Criteria?

Is it possible to create a "List from a range" Data Validation rule in Google Sheets where the range skips columns?
For example:
Cells A6:A11 is limited to the range A1:B3. Cells B6:B11 is limited to the range A1:A3 AND C1:C3 (skips column B).
Creating a Data Validation rule for cells A6:A11 is trivial as I simply need to create a Criteria of "List from a range = A1:B3".
However, creating the Data Validation rule for cells B6:B11 is not so intuitive since Google Sheets does not allow me to create a Criteria using the syntax "List from a range = A1:A3, C1:C3".
Does the "List from a range" Criteria support a syntax that allows us to skip columns within a range?
Note: I currently have a work around for this where I defined an array formula in D1 = =ArrayFormula(if({1,""},A1:A3,C1:C3)) and then use D1:E3 as the Data Validation range. But this is a hacky solution and I'm hoping there is a better way to accomplish my goal.
The solution is to use { } to create a combination of columns or rows that will result in some sort of virtual table on-the-fly.
Example:
Assuming you have a spreadsheet with Name, Age, Gender, Phone and Address in A, B, C, D and E, and you want to skip the Gender (column C) while using the UNIQUE statement, you can use something like this.
Put in G1 the following formula:
=UNIQUE({A1:B, D1:E})
From the cell G1, the spreadsheet will populate the columns G, H, I and J with unique combinations of A, B, D and E, excluding the column C (Gender).
The same application of a combined range can be used in any formula and also you can combine multiple different ranges, including cross Spreadsheets and Files.
It is a very useful trick if you need to combine pieces of multiple spreadsheets for data visualization or reports. However, always remember you cannot manipulate the displayed data. You can still search through it, format it, etc., but you cannot change it. On the other hand, it will auto-update always if the data source gets updated, which is very useful.
Note: Try it with LOOKUP, VLOOPUP or HLOOKUP.

Merging Group by and order by in Oracle

This is what I have and below what I want to do. d. is a table, and act is a view that consists of about 50 combined tables:
SELECT d.extensionaspect1 AS "Exception ID",
d.causedat AS "Date",
max(act.date_) AS "Causedate",
act.prodsteppath AS "Production Step",
--I'm calling other selections on d, but i'm not going to incude
--them for the sake of clarity
FROM pasx.deviationevent d,
pasx.vtemp_prodsteppath act
--There's more here, but I'm not going to include them for the sake of clarity
WHERE act.date_ < d.causedat
--as before, there's a large amount of AND clauses here that make
--sure that I get the timestamps I want. This is a pretty complex query
GROUP BY d.causedat,
ORDER BY d.extensionaspect1;
Running like this gives me ORA-00936; missing expression. I'm very new at this, so I'm probably fundamentally misunderstanding how to use select max(act.date_) and use it to find the timestamp that occurred just before d.causedate. act.date_ contains all the possible timestamps that could lead to throwing an exception, but only the one before the timestamps in d.causedat are relevant to me.
vtemp_prodsteppath is a view and contains no order or group by's. How do I join these two tables (d and act) together? What expression am I missing?

Access 2013: Check if a value is present in another table

I've just discovered Access, having always been an Excel/VBA man... and now I've hit a roadblock!
I'm building an inventory database for my employer. I have 2 tables, one containing one column of 'stockID's (lets call this table 'tblWarehouse'), and another containing two columns: a column of 'orderID's and a column of 'stockID's (lets call this table 'tblOrders'). (For the sake of this question, lets disregard things like quantity, price etc)
We don't keep all the goods we sell in our own warehouse, some are sourced directly from the manufacturer to the customer, which means that not all tblOrders!stockID will be present in the list tblWarehouse!stockID. I need to find out when this is the case!
I want to create a third column in tblOrders containing a dummy variable = 1 if that particular item is in our warehouse. In other words, I want to create a calculated column = 1 if tblOrders!stockID can be found in tblWarehouse!stockID. Can this be done?
I've found that I can't reference another table directly, so I've been trying my hand at queries, user defined functions and relationships, but to no avail. I've also been having trouble with the Access-lingo and veritable forest of different places to input seemingly the same expressions... so please, if u have an answer for me, be sure to specify where things are located!
Much obliged!!
If you are linking the two tables in a query using an inner join, only order records having at least one stock entry will be included in the result. In order to include those with no stock entry at all, create a left outer join.
SELECT O.OrderID, IIf(IsNull(MAX(W.StockID)), 0, 1) AS StockAvailable
FROM
tblOrder O
LEFT JOIN tblWarehouse W
ON O.StockID = W.StockID
GROUP BY O.OrderID
You can also determin the join type in the query designer by right clicking a relation line and selecting "Join Properties" and then select "Include ALL records from tblOrders ...". You can make a grouping query by clicking the big Sigma-symbol in the symbol list.

Altova Mapforce: Joining XML Input and conditional SQL Join using two tables

I'm trying to get the following done: Using Altova Mapforce, I use an XML file with schema as a source. I want to map it to exactly the same output, but only add data to one field.
The value of the field (it's Tax) is determined using a two table SQL join with a WHERE clause over both tables. The tables are joined using foreign keys, the relation is recognized by Mapforce.
The first field of the WHERE clause comes from the first table (header type table), the second and third field from the second tables (lines type tables).
However, I cannot seem to create the logical and correct equivalent of what I am describing here. I've tried it using complex AND constructions where it then inserts the one field I would need multiple times. I've tried WHERE clauses but they fail as they never supply both tables at the same time and there seems to be no way to use a pre-specified JOINing of two tables as a source. The WHERE clause then recognizes only the fields from the first table, not the second one.
Is there an example for this? Joining two (or more) tables, using WHERE to determine the exact row, then using a value from that row?
Best wishes.

Resources