I'm here again. I'm developing an example of tabular model on Analysis Services and I've an error that I'm not able to solve.
This is my tables diagram just now:
The relevant tables are MARCHAMOS, ARFABRI and DimFecha (the top ones). MARCHAMOS and ARFABRI are joined by 2 relationships (2 fields of MARCHAMOS could be paired with 1 field of ARFABRI (depends of the situation)).
Now I'm trying to get a measure with the following DAX query:
UnidadesFrescosCompradas:= countx(
calculatetable(
filter(
marchamos;
not isempty (relatedtable('ARFABRI'))
);
MID(MARCHAMOS[REGIS03]; 1; 1) = "1";
TIPOS_COCHINILLO[GRUPO]=0;
userelationship(MARCHAMOS[REGIS28];ARFABRI[ARFA01]);
userelationship(ARFABRI[ARFA06]; DimFecha[Fecha])
);
[regis01])
As you can see, I'm telling the system the relationships that it must use (one of them is from MARCHAMOS to ARFABRI and the other one is from ARFABRI to DimFecha). But I get this error:
If I remove the "userelationship(ARFABRI[ARFA06]; DimFecha[Fecha])" caluse of the filter, the error disappears, but the result is not correct.
I don't understand this, since both relationships are not over the same tables.
Any hint?
Thank's in advance
You can USERELATIONSHIP with both active and inactive relationships. It looks like you have an ambiguity in that you have two eligible relationships for MARCHAMOS and ARFABRI.
Since the ending point column for ARFABRI is the same in both relationships you get the error.
Can you delete the inactive relationship?
Related
Let me explain how I am making things (maybe not the best way by the way).
I want to join my StoreSchedule entity (which contains a triple relation : store (which is where I stock all informations about adress, name, picture of my stores), days (the 7 days of the week) and Schedules (only strings like '09:00-22:00').
To combine thoses 3 entities, I made StoreSchedule, that has a triple relation where I cross the 3 informations. Maybe I am not explaining well, let me show you some screens.
What I already tried to do with my QueryBuilder in my repository:
https://imgur.com/a/bE52iBH
How I structured things in my StoreSchedule table :
https://imgur.com/a/6m7YkhI
My Schedule table :
https://imgur.com/a/75bRriS
Days table contains the 7 days of the week. Maybe that's obvious, maybe not.
So here's the thing, I can't figure out how to make the I need : a query that gets all content from Store and joins StoreSchedule where ID = Store.ID
I want to get days and Schedule with the ID from store.
Can I do that with query builder?
Do I have to modifiy my database? Are my relations good?
Best regards!
ps : hope I made myself clear enough..
You make it too complicated. You can purge the days table AND StoreSchedule. Just make a many-to-one relation between Store and (Store)Schedule. Add a column "day" in your schedule table. A short integer will do if you store the number of the day. See php's date function.
For your query (the first link) you won't need that WHERE clause. Doctrine will join the related data automatically for you.
public function getAllContentStoreAndSchedule()
{
return $this->createQueryBuilder('st')
->leftJoin('st.schedule', 'sc')
->addSelect('sc')
->orderBy('st.name', 'ASC')
->addOrderBy('sc.day', 'ASC')
->getQuery()
;
}
I am running Analysis Services 2008 R2 and have come across some behavior that I really do not understand and I can't seem to get to the bottom of it. I have a dimension called Segment which is a simple Parent-child dimension where only one of the four top-level members has any children. This one member, has two children. Only leaf nodes have any values.
In the dimension I have used AttributeAllMemberName to allow "All Segments" to be used to refer to the top-level members. There are three dimensions used in the cube: Segment, Country and Year.
When I run:
SELECT {{Descendants([Country].[Global],, SELF_BEFORE_AFTER)}} ON ROWS,
{[Segment].[All Segments].children}*{[Measures].[Volume tonnes]} ON COLUMNS
FROM [Market]
WHERE [Year].[2012]
I see all members on the columns but the one node that has children has an empty column. My understanding is that "children" should show me only one level not two. If, on the other hand I run
SELECT {{Descendants([Country].[Global],, SELF_BEFORE_AFTER)}} ON ROWS,
{[Segment].[(all)].[All Segments].children}*{[Measures].[Volume tonnes]} ON COLUMNS
FROM [Market]
WHERE [Year].[2012]
I see exactly what I would expect; the four top-level children with correctly aggregated values for the one child that has its own children. No grand-children are shown. In either case the right number of rows are displayed.
The only difference between the two queries is that the "[(all)]" level has been explicitly listed in the second query. Given that the "all" member is defined as the only member of the "(all)" level set, these two queries should return the same values but they don't. I must be missing something in the dimension config, but what? Can someone point me in the right direction to fix this? I need the query to work properly without having to use "[(all)]".
To stop this post becoming too bloated, I have posted some screen-grabs of BIDS to my own website to show the configuration of the dimension. There are three attributes and the dimension itself that require configuration but I can only post two links so have linked them all in from this page: http://coolwire.co.uk/share/BIDS.html
The Hierarchy and the Ordering are related to the Key by rigid attribute-relationships.
It all looks okay to me but the problem must be in here somewhere.
I am completely new to SSAS an I am trying to deploy a simple cube with only one dimention comprised of multiples attributes. What I did already was to create a DSV from my data source and then I created a dimension from my fact table. It seams that no matter what happens, I get the following error message:
Errors in the OLAP storage engine: A duplicate attribute key has been found when processing: Table: 'dbo_Fact_Statistics', Column: 'Team', value: 'ANA'. The attribute is 'Team'.
This is my hierarchy: Id (SK) -> Player id -> Team -> Player Name -> Salary
I don't understand, obviously the problem is not that the value is null, like I've seen in other threads, telling me to set NullProcessing under KeyColumns to something else than automatic, but this is not the problem in this context.
Any help would be greatly appreciated.
Probably you have Team ANA listed under multiple Player Names and/or Salary values.
This is a really tricky area of SSAS. The quickest way forward is probably to install BIDS Helper and use the "Dimension Health Check" function:
http://bidshelper.codeplex.com/wikipage?title=Dimension%20Health%20Check&referringTitle=Documentation
It will show you all the issues in your data (not just the first one which you have discovered so far) and give you some info on how to proceed.
Personally I've gone off building attribute relationships due to the difficulty of debugging and fixing these issues. I tend to build dimensions now where every attribute relates directly to the key attribute. You never see these errors and performance seems very similar. You can still present the users with hierarchies.
If that is not an option for you, then you could try adding the columns for the higher-level attributes to the Key property of all the lower levels. Technically this will work but it is awkward to set up and maintain.
This approach solved my problem:
Instead of having the attributes following chained relationships, I simply leave the relationships as they were by default.
Player id (SK) -> Conference
Player id (SK) -> Division
Player id (SK) -> Team
Player id (SK) -> Player Name
Player id (SK) -> Salary
run this in sql find your douplicate for example ID... used it as my dimension key
Select id,count(*) as how_many
from [RC_Dailer_WH].[dbo].[RC_call_logs]
group by id
having count(*) > 1
(3647 row(s) affected) of which there are more than 50k records in my DB
removed duplicates then my cube processed proper
go for that dimension on which it is showing error.
and right click
go for view code
and search for the below line in that code:
ReportAndStop
delete that XML tag
and save
and reprocess it will works
Go to dimension for which it is showing Error. and give right click - go to view code -
CTRL+F - sarch for Connection - find
ReportAndStop
connection String.
Delete the above Command from the Code – and Save.
Process it again.
It will work.
So, another in my series of Kohana 3 ORM questions :)
I have, essentially, a pivot table, called connections. The connections table connects a song to a keyword. That's all great and working (thanks to my last two questions!)
I want to output the most connected songs by keyword. So, to somehow query my connections table and output an object (with an arbitrarily limited number of iterations $n) that ranks songs by the number of times they have been connected, ie. the number of times that particular song_id appears for that particular keyword_id.
I have literally no idea how to achieve this, without querying every single row (!!!) and then counting those individual results in an array.... There must be a more elegant way to achieve this?
I believe this is more of an SQL question. Using the DB query builder:
DB::select('songs.*')->select(array('COUNT("keywords.id")', 'nconnections'))
->from('songs')
->join('connections', 'LEFT')->on('connections.song_id', '=', 'songs.id')
->join('keywords', 'LEFT')->on('connections.keyword_id', '=', 'keywords.id')
->group_by('songs.id')
->order_by('nconnections')
->as_object('Model_Song')
->execute();
or in SQL
SELECT `songs`.*, COUNT(`keywords`.`id`) AS `nconnections` FROM songs
LEFT JOIN `connections` ON `connections`.`song_id` = `songs`.`id`
LEFT JOIN `keywords` ON `connections`.`keyword_id` = `keywords`.`id`
GROUP BY `songs`.`id` ORDER BY `nconnections`
should return the result you want.
You'll want to have an accessible property called nconnections in your song model. The simplest way to do that is to add a public member so you don't tamper with ORM's inner workings.
I'm assuming you're using a model called 'Song', linked to a 'songs' table, a 'Keyword' model linked to a 'keywords' table and in the 'connections' table foreign keys 'song_id' and 'keyword_id' for each model respectively.
I have a star schema with Implicit Fact division as shown in Figure 5 at http://www.information-management.com/infodirect/20020308/4858-1.html?pg=2.
My question is how do I set up the Dimension Usage? My first thought was to set up 3 Referenced Relationships (CustomerGroup to InvoiceItemFacts, GroupToCustomer to CustomerGroup, CustomerDimension to GroupToCustomer), but when I try this I get the message "A loop was found in the data source view at the 'dbo_CustomerGroup' table".
Update:
I have found that if I create a Regular Relationship between GroupToCustomer and InvoiceItemFacts (effectively by passing the CustomerGroup table because I already have the Customer Group Key) I can get some results. However, when I browse the cube and display the InvoiceItemFacts by Customer, the InvoiceItemFacts only display on the first Customer in the group.
GroupToCustomer looks to be a "Fact-less Fact Table", so you would create a measuregroup on that, doesn't need to be visible to the end users, then do a Many-Many join via that fact in the dimension usage tab.
It's a little complicated by the extra table in the way, but that should be the approach.