Can I create a (new) lookup table in Power Pivot by querying other tables in my data model? - dax

Context:
I am creating a dashboard in Excel based on the data model I am building in Power Pivot. The source data in the data model is based on various other excel tables I am regularly receiving and copy-pasting into my workbook (their incoming structure is out of my control). My goal is to perform all data processing within Power Pivot/DAX rather than manipulating the data in the worksheets before loading into the model.
Problem:
In my model, I have a table (tabCases) which includes status updates on all cases from a management system. This table has a column named case-ID (not unique). I need to create a lookup-table with unique case-id's where I can create new columns with various KPIs for each case.
How can I do this in Power Pivot?
I found two suggestions in this article but none of them work for me (opt. 1 because it requires a manual creation of the unique ID list and opt. 2 because I don't have a database access).
In my mind there should be something really simple I could do, such as i.e.:
Add new table to data model
Set first column to be equal to DISTINCT(tabCases[caseID])
Is there such a way?

A Linkback Table might help you. Please see the link below:
https://www.sqlbi.com/articles/linkback-tables-in-powerpivot-for-excel-2013/
Thanks

Related

How to avoid circular dependency error in multiple calculated columns when deleting all data in data model?

Context:
I have a data model in Power pivot with three tables, tTasks, tCaseworks and tCaseworkStatus. I am attempting to create two calculated columns in tCaseworks which from the two data tables. All three tables are linked through the common field casework_id (see illustration below).
The data model is regularly updated with new data. The way I am doing this is as follows:
All three tables are sourced from three corresponding tables in my Excel workbook.
A VBA script deletes all records in the three Excel tables and then refreshes the data model (sidenote: because the data model demands lookup tables to not be empty the VBA code adds one row per table before refreshing).
New data is then added to the excel tables and the data model is refreshed.
This process works perfectly.
Problem:
The problem arises when I am adding calculated columns to tCaseworks and then attempting to update the data as described above. I have added two calculated columns; has_task and status_now. I am using the following DAX code:
has_task:
has_task =
IF (
CONTAINS (
RELATEDTABLE ( tTasks );
tTasks[casework_id]; tCaseworks[casework_id]
);
"Yes";
"No"
)
status_now:
status_now =
VAR TableX = RELATEDTABLE(tCaseworkStatus)
VAR ResultX = IF(
CONTAINS(TableX;tCaseworkStatus[casework_status_code];"Completed");"Completed";
IF(CONTAINS(TableX;tCaseworkStatus[casework_status_code];"Dismissed");"Dismissed";
IF(CONTAINS(TableX;tCaseworkStatus[casework_status_code];"Begun");"Begun";
IF(CONTAINS(TableX;tCaseworkStatus[casework_status_code];"Created");"Created";
"Find no status"))))
RETURN
ResultX
Both of these calculated columns work as expected as long as I do not delete the data in the model (I do have one hickup with both columns as described in this separated problem, but I think that is unrelated).
When the data has been deleted and I refresh the model I get the following error message:
"We cannot get the data from the data model. This is the error message we got: A circular dependency was discovered: 'tCaseworks'[status_now],'tCaseworks'[status_now],'tCaseworks'[has_task],'tCaseworks'[has_task],'tCaseworks'[status_now]."
Question:
What is creating this dependency and how can I avoid it?
My attempted solutions:
The problem only arise when there are two of these calculated columns. Any one of these two works perfectly without the other upon refreshing. I know that calculated columns are prone to circular problems, but unfortunately I need to use columns and not measures. I suspect that perhaps my choice in formula is creating the problem, most likely the contains-function. However, I don't know about any alternative ways of building the formulas I need. Any suggestions?
Edit:
I originally only posted a portion of my data model as I wanted the question to be as concise as possible but I guess it might have been confusing. The whole model concerns five objects from a case handling system: Claims, Cases, Caseworks, Tasks and Action Points. These objects are hierarchical, one claim can have one or more cases, but one case can only have one claim. Similarly, a case can have several caseworks, a casework can have several tasks, a task can have several action points. Additionally, the latter four can have a status attribute which is changed regularly.
I attempted to organize my data model in such a way that I had a lookup table for each object with unique values. I have many attributes for each object in my data that I did not include in the example above, and my goal was to add useful attributes through calculated columns in these tables. The data tables with the changes were intented to provide insight to the lookup tables.
I think your relationship model is a bit unusual. DAX works best when using something like dimensional fact model
I would consider the tCaseworkStatus a fact table since its like a log of the changes to your data. tTasks is a dimension, since it just add an extra dimension to your data.
The tCaseworks is not necessary since it doesn't hold any actual data (only calculated data).
if you want your current model to work, it might fix your problem if you just delete the relationship between tTasks and tCaseworks, and add a new between tTasks and tCaseworksStatus
edit.
it just occurred to me that the reason you have it like this, is that you may have a many-to-many relationship between tTasks and tCaseworksStatus. if that is the case you might have to create a proper many-to-many table. which is kind of what your tCaseworks is, but you cant have a relationship to the same key like you currently have.
edit2.
the solution seemed to be that somehow the Relatedtable function in conjunction with the relationship model was causing the error. using Lookupvalue instead seems to to have fixed the issue.

Variance Column in BI Publisher Report Pivot Table

I have a data model using a private data source (not from a Subject Area), so I need to do this with a BI Publisher Report (not an Analysis).
In the data model I have a column called 'Financial Plan Type' that contains a few different values such as "Forecast", "Adjusted Budget", "Original Budget", etc.
I want to create a pivot table that pivots this column and then creates a variance column between "Adjusted Budget" and "Forecast" as example. Obviously I have an 'Amount' field in the table too.
It doesn't seem that I can do this directly in the report as the formulas and flexibility seem to be limited for the Reports (although I'm not 100% sure of this as I am fairly new to OBIEE), but I was thinking that I could adjust the data model to union in a variance amount or do something else with the data model to make this work. Does anyone have any ideas and/or best practices around doing this either in the data model or in the Report itself?
This going to be abstract, but you can do this in BIP or Analysis, depends on what the data source looks like.
If you have are able to compute the variance as an extra element in the datasource (might need to model it), then BIP RTF template designer does support Pivot tables. You might still need to add some XDO code in the loops.
If you are inclined to OBIEE, you can create your OWN data source on OBIEE. You will have to use the RPD data modeller if you are on OBIEE on premise, or write the transactional SQL if you are OTBI on the cloud.
Either way, the trick is to have the variance already computed in the XML, so BIP/OBIEE can simply print it off.

How to store different type and number of fields in one database table?

Hello everybody I'm making a "Bulletin board", like this: http://stena.kg/ad/post, I'm using Laravel 5.0, and don't know how to store different fields in database table, for example if I choose "Cars" category I should to fill Mark, Model, Fuel (etc fields for cars category), If I choose Flats category I should fill fields like Area, Number of rooms etc...How to organize all of this? I tried some ideas but nothing helped me(
Try to save data as json in table. Parse json format to string and save it in db, but it will cause many problems in future, so not recommend that solution. I recommend to store data in separate tabels, each one for category. For optimise process it is possible to create catregory table, and category_item table with fields like name, description and so on. Different category demands sp=ecific fields, so best solution is to create table per category.

Data dictionaries and functionality behind Code Road Map

I was looking to a Code Road Map feature that Toad provides which shows dependencies of Objects.
Can anyone tell me on what basis the Toad Generate the Dependencies? I am assuming that there is a data dictionary view exists dba_dependencies which work at the backend for getting this relation.
So can we write a script to which we pass object name like package name, table_name amongst others that will show the dependency of the object passed by me.
In code Road Map there is an option to generate data for a table ...how does this work?
What is the algorithm behind it? If there is foreign key on the child table and the parent table is empty, how does this work? How it will populate the depending table first and then the child table.
Looking at user_depencies/ dba_dependencies view structure, querying the view with column REFERENCED_NAME equal to the object that you want to query with should provide you with a list of objects where the object you're searching for is referenced.
Second question is too broad & probably only the Toad developers know how they've implemented it. The data dictionaries provide information about the various constraints on a table. My guess would be the algorithm looks at data dictionary & has different code paths for handling constraints / master child relations. Another assumption would use of handled exceptions to ensure the data is generated cleanly.

database driven form controls

How to do databse driveen jsp page,
Suppose i have 5 text fields,if user wants to put one of the form field as select box.JSp should identify and return the select box if it define in db as select box.
I dont know how to achieve this,can anyone suggest this.
Regards,
Raju komaturi
There are multiple tasks if you want to do this completely. The world at large has not gone this way and so there are not many tools (if any) for this. But basically here are the main ideas.
1) You want a "data dictionary", a collection of meta-data that tells you what the types and sizes of each column are, and the primary and foreign keys are.
2) For your example of "knowing" that a field should be a drop-down, this almost always means that column value is a foreign key to another table. Your code detects this and builds a listbox out of the values in the parent table.
3) You can go so far as to create a complete form generator for simple tables, where all of the HTML is generated, but you always need a way to override this for the more complex forms. If you do this, your data dictionary should also have column descriptions or captions.
There are many many more ideas, but this is the starting point for what you describe.

Resources