DAX - Unique count between RELATED tables
Hi all,
Having a little trouble with the RELATEDTABLE function. I'm trying to get a distinct count of a specific value from one table into another table. I want to get the total count of "Red" from the 'Color' table into the 'Master' table
for each unique ID.
The 'Color' table is this:
ID
Color
1
Red
2
Green
3
Red
1
Green
2
Red
3
Red
1
Red
The 'Master' table should look like this in the end:
ID
Name
Red
1
John
2
2
Mark
1
3
Jason
2
Any thoughts? Thanks.
UG1
Sounds like this
=COUNTROWS(FILTER(RELATEDTABLE(TabB),TabB[Color]="RED"))
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Similar Messages
-
Count between (1 table)
I want ONLY the IDs which:
* have "LAP" Between 0901-1033
* have "UNIT" count as 1
Table 1
ID UNIT LAP
1 POL 0902
1 OOP 1006
2 LOP 1033
3 SIN 1101
4 OOP 0905
4 OOP 1001
5 LIP 8001So:
ID 1 = No because UNIT count is 2
ID 2 = YES
ID 3 = NO "LAP" out of range (not between 0901-1033)
ID 4 = NO Even though its same unit, its been repeated. Only want once.
ID 5 = NO "LAP" out of range (not between 0901-1033)
Thanks for help.
Edited by: Chloe_19 on 29/04/2012 21:42Another way could be :
with count_check as
(select count(id) ct,id from tablename group by id)
select a.* from tablename a,count_check b where a.id=b.id and b.ct <2 and a.lap between 0901 and 1033;
@Kiran, Good way of using 1>= . I have never seen this thing before :). Thanks -
How to define join in physical layer between cube and relational table
Hi
I have a aggregated data in essbase cube. I want to supplement the information in the cube with data from relational source.
I read article http://community.altiusconsulting.com/blogs/altiustechblog/archive/2008/10/24/are-essbase-and-oracle-bi-enterprise-edition-obiee-a-match-made-in-heaven.aspx which describes how to do it.
From this article I gather that I have to define a complex join between the cube imported from essbase to my relational table in physical layer.
But when I use Join Manager I am only able to define jooin between tables from relation source but not with the imported cube.
In My case I am trying to join risk dimension in the cube based on risk_type_code (Gen3 member) with risk_type_code in relation table dt_risk_type.
How can I create this join?
Regards
DhwajHi
This has worked the BI server has joined the member from the oracle database to cube. So Now for risk type id defined in the cube I can view the risk type code and risk type name from the relational db.
But now if I want to find aggregated risk amount against a risk type id it brings back nothing. If I remove the join in the logical model then I get correct values. Is there a way by which I can combine phsical cube with relational model and still get the aggregated values in the cube?
I have changed the column risk amount to be sum in place of aggr_external both in logical and phsical model.
Regards,
Dhwaj -
Relation between MSEG table and movement types in 2lis_03_bf
Hi all,
May i know the relation between MSEG table and 2lis_03 _bf xtractor stock type/stockcategory where we see the informarion in r/3 side for this, you answers gets rewarded.
regards,
Dan.Hi,
Most of the data for IM comes from the tables MSEG andd MKPF. You can go to MSEG contents and see the data there. You will find all the movement types, stock types and stock categories there. You can also use the transactions MB5B, MB51 etc.. to see the related info in R/3. As I said most of the data comes from these tables but not all the data. It uses some internal programming to get the data.
Hope it helps... -
Count Records in Table Except If Related Record Exists in Child Table
Dear All
I have the following query that counts all of the records in the table SENAlert based upon the teacher's username in a related table.
SELECT COUNT(SENAlert.SENAlertID) AS Expr1
FROM Class INNER JOIN ClassMember ON Class.ClassClassCode = ClassMember.ClassMemberClassCode
INNER JOIN Student ON ClassMember.ClassMemberStudentID = Student.StudentID
INNER JOIN SENAlert ON Student.StudentID = SENAlert.SENAlertStudentID
INNER JOIN Teacher ON Class.ClassTeacherCode = Teacher.TeacherCode
WHERE (Teacher.TeacherUsername = 'dsmith')
I need to extend this query by adding another table called SENAlertHistory. I would like to count the number of alerts (SENAlertID) for the specified teacher
but where there is no related record in the SENAlertHistory table. Here's what the relationship diagram looks like:
What's going to happen is when a teacher clicks a button to say they have read an alert, I will record this in the SENAlertHistory table. Therefore when performing a count of how many unread alerts the teacher has, I need to ignore the alerts they have
already read (i.e. the records in the SENAlertHistory table).
This is a bit too advanced for me -- I have tried! I was hoping someone would be able to help me please?
Many thanks
DanielTry below code
-- If you dont need the read alert count
SELECT COUNT(SENAlert.SENAlertID) AS Expr1
FROM Class INNER JOIN ClassMember ON Class.ClassClassCode = ClassMember.ClassMemberClassCode
INNER JOIN Student ON ClassMember.ClassMemberStudentID = Student.StudentID
INNER JOIN SENAlert ON Student.StudentID = SENAlert.SENAlertStudentID
INNER JOIN Teacher ON Class.ClassTeacherCode = Teacher.TeacherCode
WHERE (Teacher.TeacherUsername = 'dsmith')
AND NOT EXISTS
(SELECT * FROM SenAlertHistory SAH WHERE Teacher.TeacherCode = SAH.SenAlertHistoryTeacherCode and SENAlert.SENAlertID = SAH.SEMAlertHistorySENAlertID )
-- If you need the read alert count
SELECT COUNT(SENAlert.SENAlertID) - COUNT(SAH.SEMAlertHistorySENAlertID) AS Expr1,COUNT(SAH.SEMAlertHistorySENAlertID)readalert
FROM Class INNER JOIN ClassMember ON Class.ClassClassCode = ClassMember.ClassMemberClassCode
INNER JOIN Student ON ClassMember.ClassMemberStudentID = Student.StudentID
INNER JOIN SENAlert ON Student.StudentID = SENAlert.SENAlertStudentID
INNER JOIN Teacher ON Class.ClassTeacherCode = Teacher.TeacherCode
LEFT OUTER JOIN SenAlertHistory SAH ON Teacher.TeacherCode = SAH.SenAlertHistoryTeacherCode and SENAlert.SENAlertID = SAH.SEMAlertHistorySENAlertID
WHERE (Teacher.TeacherUsername = 'dsmith')
Thanks
Saravana Kumar C -
What is the Relation between System Tables and FND Table?
Hi,
I have two LOV's. First one is Module Name. Here I will select Module Name as GL, AP, AR.... In the second LOV it should populate all the API's available in the module. I tried with the following tablesFND_APPLICATION AND ALL_SOURCES. But there is no relation between these tables.
Can anyone suggest me..
Please help me out.
Thanks in Advance,
SateeshHi,
I have two LOV's. First one is Module Name. Here I will select Module Name as GL, AP, AR.... In the second LOV it should populate all the API's available in the module. I tried with the following tablesFND_APPLICATION AND ALL_SOURCES. But there is no relation between these tables.
Can anyone suggest me..
Please help me out.
Thanks in Advance,
Sateesh -
Relations Between MLCD table and material movements type
Dear all,
I Have a question about relations between MLCD table and Material movements. For Example We have a movement type Z71 when we did a movevent with tis movement type from MB1C Transaction. System creates a record in Mlcd Table. in this table Category field is VN and PCat field is V. How system decides about VN and V
is there any table which contains these conversions or is there any custimization in MM or CO modules ?
Could you please help me if you have any information about subject.
Best RegardsHi Anupam
Thanks for your speedy reply.sorry i forget to mention i need FG materials details for given plant,production version,metrial type.In
MKAL i am not able to give material type as input parameter
Regards
Bala -
How to check relation between two tables in same database
How to check relation between two tables in same database using Oracle SQL developer. Version 2.1.1.64
Hi,
Try this,
SELECT cons.owner AS child_owner, cons.table_name AS child_table,
cons.constraint_name constaint_name,
cons.constraint_type constraint_type, col.owner parent_owner,
col.table_name parent_table, col.column_name column_name
FROM dba_cons_columns col, dba_constraints cons
WHERE cons.r_owner = col.owner
AND cons.r_constraint_name = col.constraint_name
AND col.owner = 'MY_USER'
ORDER BY child_table;Thanks,
Shankar -
Make relation between 2 table programilly
how can I make a relation between 2 tables ( one to many) through code
and also broke this relation through codeYou just need these commands:
https://msdn.microsoft.com/en-US/library/zkyz3407%28v=vs.80%29.aspx
https://msdn.microsoft.com/en-US/library/sdwsys0z(v=vs.80).aspx
Bye, Olaf.
Olaf Doschke - TMN Systemberatung GmbH http://www.tmn-systemberatung.de -
Link between Komv structure and related table
hai,
I have one problem in CIN.
In Purchase Order for
ED - JM01 or JEXC
CESS -ZECS or JEC1
CSTLST - JIP1 or JIP2
stored in KOMV Structure,
other than KOMV TABLE where this values are stored..
(In KONV no values found for that one)
pLEASE, tell me Table name .....in which i get above condition value
thank you
Manoj..Hi,
1)GOTO>SE11>Open the table.
2)Just beside the CONTENTS & DISPLAY BUTTON-->Click on Graphics Button
3)New Graphics window ill popup.
4)check for the forign key and check table button.
you will find all the related tables,and Relations.
This will be very helpful for future reference also.
Hope it resolves the query.
Regards,
Gurpreet -
How to implement Master - Detail relation between two table views in OBI11g
Hi Gurus,
I was able to create master- detail between table and graph.
But between two tables not.
I put the listening column on the table prompt and specified channel for the Listen to Master-Detail Events in the table properties.
But did not work.
Where is the mistake?
I"d appreciate any ideas, help!
Thanks
LaszloThanks for the link!
My question is :
Are the same thinga the page edge and table prompt for the tables?
If not how to add a column to the page edge (not to the table prompt)?
Thanks
Laszlo -
Approach to parse large number of XML files into the relational table.
We are exploring the option of XML DB for processing a large number of files coming same day.
The objective is to parse the XML file and store in multiple relational tables. Once in relational table we do not care about the XML file.
The file can not be stored on the file server and need to be stored in a table before parsing due to security issues. A third party system will send the file and will store it in the XML DB.
File size can be between 1MB to 50MB and high performance is very much expected other wise the solution will be tossed.
Although we do not have XSD, the XML file is well structured. We are on 11g Release 2.
Based on the reading this is what my approach.
1. CREATE TABLE XML_DATA
(xml_col XMLTYPE)
XMLTYPE xml_col STORE AS SECUREFILE BINARY XML;
2. Third party will store the data in XML_DATA table.
3. Create XMLINDEX on the unique XML element
4. Create views on XMLTYPE
CREATE OR REPLACE FORCE VIEW V_XML_DATA(
Stype,
Mtype,
MNAME,
OIDT
AS
SELECT x."Stype",
x."Mtype",
x."Mname",
x."OIDT"
FROM data_table t,
XMLTABLE (
'/SectionMain'
PASSING t.data
COLUMNS Stype VARCHAR2 (30) PATH 'Stype',
Mtype VARCHAR2 (3) PATH 'Mtype',
MNAME VARCHAR2 (30) PATH 'MNAME',
OIDT VARCHAR2 (30) PATH 'OID') x;
5. Bulk load the parse data in the staging table based on the index column.
Please comment on the above approach any suggestion that can improve the performance.
Thanks
AnuragTThanks for your response. It givies more confidence.
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
TNS for Linux: Version 11.2.0.3.0 - Production
Example XML
<SectionMain>
<SectionState>Closed</SectionState>
<FunctionalState>CP FINISHED</FunctionalState>
<CreatedTime>2012-08</CreatedTime>
<Number>106</Number>
<SectionType>Reel</SectionType>
<MachineType>CP</MachineType>
<MachineName>CP_225</MachineName>
<OID>99dd48cf-fd1b-46cf-9983-0026c04963d2</OID>
</SectionMain>
<SectionEvent>
<SectionOID>99dd48cf-2</SectionOID>
<EventName>CP.CP_225.Shredder</EventName>
<OID>b3dd48cf-532d-4126-92d2</OID>
</SectionEvent>
<SectionAddData>
<SectionOID>99dd48cf2</SectionOID>
<AttributeName>ReelVersion</AttributeName>
<AttributeValue>4</AttributeValue>
<OID>b3dd48cf</OID>
</SectionAddData>
- <SectionAddData>
<SectionOID>99dd48cf-fd1b-46cf-9983</SectionOID>
<AttributeName>ReelNr</AttributeName>
<AttributeValue>38</AttributeValue>
<OID>b3dd48cf</OID>
<BNCounter>
<SectionID>99dd48cf-fd1b-46cf-9983-0026c04963d2</SectionID>
<Run>CPFirstRun</Run>
<SortingClass>84</SortingClass>
<OutputStacker>D2</OutputStacker>
<BNCounter>54605</BNCounter>
</BNCounter>
I was not aware of Virtual column but looks like we can use it and avoid creating views by just inserting directly into
the staging table using virtual column.
Suppose OID id is the unique identifier of each XML FILE and I created virtual column
CREATE TABLE po_Virtual OF XMLTYPE
XMLTYPE STORE AS BINARY XML
VIRTUAL COLUMNS
(OID_1 AS (XMLCAST(XMLQUERY('/SectionMain/OID'
PASSING OBJECT_VALUE RETURNING CONTENT)
AS VARCHAR2(30))));
1. My question is how then I will write this query by NOT USING COLMUN XML_COL
SELECT x."SECTIONTYPE",
x."MACHINETYPE",
x."MACHINENAME",
x."OIDT"
FROM po_Virtual t,
XMLTABLE (
'/SectionMain'
PASSING t.xml_col <--WHAT WILL PASSING HERE SINCE NO XML_COL
COLUMNS SectionType VARCHAR2 (30) PATH 'SectionType',
MachineType VARCHAR2 (3) PATH 'MachineType',
MachineName VARCHAR2 (30) PATH 'MachineName',
OIDT VARCHAR2 (30) PATH 'OID') x;
2. Insetead of creating the view then Can I do
insert into STAGING_table_yyy ( col1 ,col2,col3,col4,
SELECT x."SECTIONTYPE",
x."MACHINETYPE",
x."MACHINENAME",
x."OIDT"
FROM xml_data t,
XMLTABLE (
'/SectionMain'
PASSING t.xml_col <--WHAT WILL PASSING HERE SINCE NO XML_COL
COLUMNS SectionType VARCHAR2 (30) PATH 'SectionType',
MachineType VARCHAR2 (3) PATH 'MachineType',
MachineName VARCHAR2 (30) PATH 'MachineName',
OIDT VARCHAR2 (30) PATH 'OID') x
where oid_1 = '99dd48cf-fd1b-46cf-9983';<--VIRTUAL COLUMN
insert into STAGING_table_yyy ( col1 ,col2,col3
SELECT x."SectionOID",
x."EventName",
x."OIDT"
FROM xml_data t,
XMLTABLE (
'/SectionMain'
PASSING t.xml_col <--WHAT WILL PASSING HERE SINCE NO XML_COL
COLUMNS SectionOID PATH 'SectionOID',
EventName VARCHAR2 (30) PATH 'EventName',
OID VARCHAR2 (30) PATH 'OID',
) x
where oid_1 = '99dd48cf-fd1b-46cf-9983';<--VIRTUAL COLUMN
Same insert for other tables usind the OID_1 virtual coulmn
3. Finaly Once done how can I delete the XML document from XML.
If I am using virtual column then I beleive it will be easy
DELETE table po_Virtual where oid_1 = '99dd48cf-fd1b-46cf-9983';
But in case we can not use the Virtual column how we can delete the data
Thanks in advance
AnuragT -
Syntax of DDL options and related (table) column names
Hi,
where can I find something like a mapping between DDL options and related table column names?
For example I do have the table options PCTFREE, FREELISTS and NOCOMPRESS. The related table columns out of user_tables are PCT_FREE, FREELIST and COMPRESS.
PCT(_)FREE wins an Underscore, FREELIST(S) wins an "S" and it is "NOCOMPRESS" if COMPRESS has a value "Y(es)".
Hope somebody can help.So far I didn't find any information that is not in
the DDL script gernerated from
DBMS_METADATA.get_DDL.Alright, I give you an example:
I create a table with the following DDL:
"CREATE TABLE IntBuch (
int_bunr integer NOT NULL,
int_sdat double precision NOT NULL,
int_hblz char(8) NOT NULL,
int_hkto char(7) NOT NULL,
int_hdat double precision NOT NULL,
KtoNr char(7) NOT NULL,
BLZ char(8) NOT NULL,
CONSTRAINT PK_IntBuch PRIMARY KEY (int_bunr)
USING INDEX
PCTFREE 10
STORAGE (
INITIAL 1000
NEXT 500
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS 4096
PCTFREE 20
LOGGING
CREATE UNIQUE INDEX intid
ON IntBuch (int_bunr DESC)
CREATE INDEX hkto
ON IntBuch (int_hblz,int_hkto)
COMMENT ON TABLE IntBuch
IS 'Kommentar zu DB-Tabelle InBuch'
COMMENT ON COLUMN IntBuch.int_sdat IS 'Kommentar zu DB-Spalte int_sdat'
ALTER TABLE IntBuch
ADD CONSTRAINT Gutschrift FOREIGN KEY (int_hkto,int_hblz) REFERENCES Konto
ON DELETE CASCADE
ADD FOREIGN KEY (KtoNr,BLZ) REFERENCES Konto
ADD FOREIGN KEY (int_bunr) REFERENCES Buchung
ON DELETE CASCADE
After that I read the DDL with DBMS_METADATA.get_DDL and I get
" CREATE TABLE "UOENDE"."INTBUCH"
( "INT_BUNR" NUMBER(*,0) NOT NULL ENABLE,
"INT_SDAT" FLOAT(126) NOT NULL ENABLE,
"INT_HBLZ" CHAR(8) NOT NULL ENABLE,
"INT_HKTO" CHAR(7) NOT NULL ENABLE,
"INT_HDAT" FLOAT(126) NOT NULL ENABLE,
"KTONR" CHAR(7) NOT NULL ENABLE,
"BLZ" CHAR(8) NOT NULL ENABLE,
CONSTRAINT "PK_INTBUCH" PRIMARY KEY ("INT_BUNR")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 16384 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ENABLE,
CONSTRAINT "GUTSCHRIFT" FOREIGN KEY ("INT_HKTO", "INT_HBLZ")
REFERENCES "UOENDE"."KONTO" ("KTONR", "BLZ") ON DELETE CASCADE ENABLE,
FOREIGN KEY ("KTONR", "BLZ")
REFERENCES "UOENDE"."KONTO" ("KTONR", "BLZ") ENABLE,
FOREIGN KEY ("INT_BUNR")
REFERENCES "UOENDE"."BUCHUNG" ("BU_NR") ON DELETE CASCADE ENABLE
) PCTFREE 20 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS"
If there are no more DDLOptions possible than that, it is fine for me. If not, but all kinds of options are to find in only one or two tables of the database ( user_tables for table options, dba_constraints and dba_segments for column options, primary and foreign keys, user_indexes and user_segments for indexes ...), that is fine for me, too. (As long as I get to know which tables are "sufficient" for that.) If it is different than both of that, that's bad.
However if you want to use defaults instead of
absolut values, it is better to remove certain parts,
like the storage clause, from the generated output.I understand this, but I am more interested to have all and not leaving out some of them in order to have the defaults in the database after running the DDL.
A totally different approach could be to
a) create a database link from one DB to another.
b) create table <new_table> as select * from
<old_table@dbLink> where 1=2;I keep that in mind, thanks for that hint. -
Difference between relational integrity and data intigrity
hi
could anybody tell me
what is the difference between
relational integrity and data intigrity
tahnx
kals.hi,
Data Integrity
Data integrity means, in part, that you can correctly and consistently navigate and manipulate the tables in the database. There are two basic rules to ensure data integrity; entity integrity and referential integrity.
The entity integrity rule states that the value of the primary key can never be a null value (a null value is one that has no value and is not the same as a blank). Because a primary key is used to identify a unique row in a relational table, its value must always be specified and should never be unknown. The integrity rule requires that insert, update, and delete operations maintain the uniqueness and existence of all primary keys.
The referential integrity rule states that if a relational table has a foreign key, then every value of the foreign key must either be null or match the values in the relational table in which that foreign key is a primary key.
What is a Relational Integrity?
A relational database contains tables of data which are related to each other. For example, articles are related to the author who wrote them, and conversely, authors are related to the articles they wrote. (Sounds obvious, and it is.) That's the relational part.
When we work with a relational database, we naturally expect that data in related tables stay related. For example, articles written by MartinB should always be related to MartinB and never be confused with articles written by any other author. That's the integrity part.
Relational Integrity is also called Referential Integrity, perhaps because the mechanism for ensuring integrity is implemented by the way the tables reference each other. Both terms are okay with me. I usually just say RI anyway.
Regards,
Sourabh -
Insertion of data between 2 tables ( 1 to * relationship )
Hi all, I am new to Oracle ADF, I have a problem with the insertion of data between 2 tables (Table A and Table B), I have the ratio 1 to *, and I need to insert data in table B (* Relationship) when insert in Table A all goes well, but when inserted in Table B, I need the primary key value in Table A () in the value field in table B that is as foreign key.
Ie
Value Table A
coda = 20 -> primary key
Table B values
1 set of values
val_1,
val_2,
val_3,
coda = 20 -> need this value is constant up to do a Commit.
set of values 2
val_1,
val_2,
val_3,
coda = 20 -> need this value is constant up to do a Commit.
How I can do it?
thanksThanks for you answers 'M.Jabr'
I was wrong, because the relationship 1 to * between tables A and B, I was writing the groovy expression in each table, in this case in Table B (A.codSolicitude), but now I notice that within the DataControls, but specifically in the control data of Table A, there is a relationship between the board B, and I thought to insert into the related table that appears as a master/detail, and first inset in table A and then in Table B in the same page master/detail, and A.CodSolicitude value is automatically filled in Table B, and performed the Commit and everything works. !
Thanks for you help.
Now if you can give me some examples with images that are on the web similar to this problem would be great:) Thanks!
Maybe you are looking for
-
Exporting book pages one at a time
When I create a photobook I need to see them in JPG so I export the pages as jpg. My problem is that I can only export all the pages which takes a long time. If I find a mistake on one page which I correct in LR there is no way to export just that on
-
Report painter question FI-GL or FI-SL?
Hello I have a general question on reports created via report painter. I want to create a BS & PL report to see balances by month, and am trying to determine considerations to take into account. Creation of a report where I can see the balance of an
-
I need help with Premiere Elements 8
I have enough rams and storage space. I am working in windows XP; I finished a project with still pictures, music, home movie clips, and title menu. I got the program to burn the first copy. I need 19 more, but the program keep "crashing". I have res
-
Auto scaling takes time to execute the rules
Hi, I am using the windows azure application. In that I am using the scaling feature provided into the azure portal. Here, I have configured the rule to scale up my web role instance by 1 if CPU load increases up to certain limit. and the reverse rul
-
Silent installation / Installer.properties issues
1)In regards to Windows 2000 server when performing a silent installation of WebLogic 6.0 how can I specify the Path for the start menu (Short cuts for launching) I can recall being able to do this prior to SP1 being bundled. Below is a copy of the i