I am trying to add a column to tablix that uses different dataset. Now the dataset1 holds new data and dataset2 holds old comparison data.
The tablix is using dataset1 and the row in question is grouped by D_ID now I added a column that needs to binded with D_ID(dataset1) to D_ID(dataset2)
=-1*sum(Lookup(Fields!D_ID.Value, Fields!D_ID.Value, Fields!BUD_OLD.Value, "OLD")+Lookup(Fields!D_ID.Value, Fields!D_ID.Value, Fields!ACK_BUD_OLD.Value, "OLD"))
However this does take into account that what I need is all the rows from BUD_OLD with D_ID = smth to be summed together. The lookup only returns one value not a sum of all values with D_ID.
Example
D_ID SUM(BUD_NEW+ACK_BUD_NEW) SUM(BUD_OLD+ACK_BUD_OLD)
**100** **75** (40+35) **15**(SHOULD BE 15+20=35)
How can I get the sum?
LOOKUP only gets a single value.
You would need to use LOOKUPSET and a special function to SUM the results.
Luckily, this has been done before.
SSRS Groups, Aggregated Group after detailed ones
From BIDS:
LOOKUP: Use Lookup to retrieve the value from the specified dataset for a name-value pair where there is a 1-to-1 relationship.
For example, for an ID field in a table, you can use Lookup to
retrieve the corresponding Name field from a dataset that is not bound
to the data region.
LOOKUPSET: Use LookupSet to retrieve a set of values from the specified dataset for a name-value pair where there is a 1-to-many
relationship. For example, for a customer identifier in a table, you
can use LookupSet to retrieve all the associated phone numbers for
that customer from a dataset that is not bound to the data region.
Your expression requires a second "sum"
Try the following:
-1*sum(Lookup(Fields!D_ID.Value, Fields!D_ID.Value, Fields!BUD_OLD.Value, "OLD")+SUM(Lookup(Fields!D_ID.Value, Fields!D_ID.Value, Fields!ACK_BUD_OLD.Value, "OLD")
Related
I'm trying to build a calculated table, containing the mapping between different datasets. The keys I'm using to do the lookup can be repeated and I would like to generate the list of all possible combinations. In SQL, this would be a join which would generate additional rows. I'm looking to do the same in DAX, with a calculated table, however LOOKUPVALUE can only return one row and will error if it finds more than one match.
A table of multiple values was supplied where a single value was expected
I feel like it could be possible with summarise columns and a virtual relationship, however when trying this, I also get an error
=SUMMARIZECOLUMNS (
Label[LabelText],
User[Dim_CustomerUser_Skey],
Computer[Dim_Computer_Skey]
,FILTER ( Computer, Label[Device] = Computer[Device name])
, FILTER ( User, Label[UserName] =User[UserName])
)
but this also gives:
Calculated table 'CalculatedTable 1': A single value for column 'Device' in table 'Label' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result
How to I produce a calculated table for a many to many?
In SQL, there are Joins. Luckily for us DAX provide joins between tables.
But first of all, what function to use for what? Here it is:
Left Outer: GENERATEALL, NATURALLEFTOUTERJOIN
Right Outer: GENERATEALL, NATURALLEFTOUTERJOIN
Full Outer: CROSSJOIN, GENERATE, GENERATEALL
Inner: GENERATE, NATURALINNERJOIN
Left Anti: EXCEPT
Right Anti: EXCEPT
Visit : https://www.sqlbi.com/articles/from-sql-to-dax-joining-tables/
I have a master table, fc_master that contains a column called fc_id. This column has values such as fc_id1,fc_id2 and so on.
I also have corresponding detail tables for each of these fc_ids in different categories, namely
category_1_fc_id1, category_2_fc_id1, category_1_fc_id2,
category_2_fc_id2.
This brings my total number of tables to 5, i.e fc_master, category_1_fc_id1, category_2_fc_id1, category_1_fc_id2, category_2_fc_id2.
I want to generate an Oracle SQL query that would allow you me provide a single fc_id as an input to automatically pull from the appropriate fc_id tables. How can I achieve this?
Please simplify/correct your table names...why use fc_id1 at one place
and fc_id_1 at another place? Can you use fc_id1 in both places? same
for 2.
Try to keep table names and column names independent of the data in
fc_id and category_id so that code is static instead of dynamic SQL.
Please redesign to use fc_master (single master) with fc_id and
fc_detail (single detail) with fc_id and category_id. Repeat the
primary keys of master table in detail table so that a single detail
table is sufficient instead of 4.
Optional - Use Partitioning as needed on fc_id (primary) as well as
category_id (secondary) if data is too large.
I currently have two tables. The first one has a bunch of information. The relevant information is the maj_cvg_code which has a value of 'opv', 'pro', 'ipa' and a maj_diag_code which is some number. When you combine both of these pieces of information you will get an actual name for each row.
The second table has the maj_cvg_code and maj_diag_code and the name. How do I get SAS/SQL to print the name of the category on each row?
What would be the expression to create a calculated column in Table Example 2 called "SZODMAXCALC", that would contain the SZODMAXCALC from Table Example 1 given that the data from Table Example 1 falls between the dates (DTTMSTART and DTTMEND) within Table Example 2?
Maybe this is easier done on the SQL side that loads the data?
there is no way to create a calculated column that references a column in another table.
you will need to do a join either in Spotfire (via Insert...Columns)* or on the SQL-side of things (either via a view on your database or by creating a new information link in Spotfire).
the best method depends on your data structure, implementation, and desired results, so I'm not able to recommed there. take a look at both options and evaluate which one works best.
* NOTE that Spotfire cannot join based on a Calculated Column as a common key. that is, using your example, if [WELLNAME] is a calculated column, you cannot tell Spotfire the equivalent of SELECT wellname, ... FROM table_a LEFT JOIN table_b ON table_a.wellname = table_b.wellname.
the alternative is to Insert...Transformation and choose Insert New Calculated Column, and to join on that instead.
the reason for this is that calculated columns are very mutable; they could change frequently based on a user action. it would be inefficient to re-execute the join each time the column's contents changed. conversely, a "Transformation Calculated Column" is only updated when the data table is loaded.
I have a report that is grouped on several fields from my dataset. However, one of the columns in my tablix is an expression, NOT a dataset field and I don't see that expression as an option to pick when I try to add it to the detail grouping.
basically, I'm pulling the vendor's name on each order. For one particular type of order (flower seed) one order can have several different vendors that actually supply the seed, but since it comes from us, WE really are the vendor. So, in the column for vendor name in my tablix, I have an expression: =IIF(Fields!major_grp.Value = "S","Seeds",Fields!vend_desc.Value) so that if it's a seed order, I make the vendor description "Seeds", otherwise I use whatever is the real value in the Field!vend_desc.value.
I need to be able to add new group expression on my calculated value, not the actual value from the dataset but it's not giving me my expression as an option to pick, just the dataset value "vend_desc". Is it possible to group on an expression in a column of a tablix?
the only other thing I thought might be possible is to calculate the value of the vendor description in my SQL select statement in the dataset that pulls the data initially, but the Select statement I'm using is EXTREMELY complex and I'd hate to make it even muddier....
You can create group on expression, in the group properties, where it says group on, add your expression there.
You can further look into the following links
http://technet.microsoft.com/en-us/library/dd220419.aspx
http://technet.microsoft.com/en-us/library/ms170712.aspx