Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
FilippoValli
Contributor III
Contributor III

How to assign null values to a dimension

first herarchical levelfirst herarchical leveldeeper hirarchical leveldeeper hirarchical levelHi,

I'm trying to find a way to solve a problem I encountered during the creation of my dashboard. I'll try to explain the situation at my best.

I have a dataset composed by two separate tables, one collecting Measures of devices(each device has it's one id code called Mu_Device), and one called Multimetri containing the devices information and hierarchical information aswell. The tabels are linked with a unique key (device's id code).

Immagine i have two devices "D1" and "D2" measuring energy consumpsion on the same power grid but two diffrent levels, one measuring the total and the other only a part of the network, so that D1=D2+k where k is the energy consuption that I need to calculate. Easy right? k=D1-D2

Currently due to herarchical classification the value of k is displayed in the correct "herarchical category " altough labled as Null

How can I create a new Multimetri row having k as value? NOTE: measure values are not contained in the same table.

I will attach some example data:

Multimetri table:

Mu_Descr_DeviceMu_LoadMu_Tipo_VettoreMu_GatewayMu_DeviceNodeIdParentId
GENERAL_PODForza Motrice+LuciElettrico10.41.26.000 
AssemblaggioForza Motrice+LuciElettrico10.41.26.23410
Illuminazione VerniciaturaLuciElettrico10.41.26.192223
VerniciaturaForza Motrice+LuciElettrico10.41.26.191330
Illuminazione AssemblaggioLuciElettrico10.41.26.231941
Illuminazione ImballaggiLuciElettrico10.41.26.272056
ImballaggioForza Motrice+LuciElettrico10.41.26.27760
Illuminazione Magazzino PFLuciElettrico10.41.26.262178
Magazzino PFForza Motrice+LuciElettrico10.41.26.261480

 

Measure table:

Mi_DeviceMi_DateMi_Measure
1301/01/20193
1902/01/20194
2003/01/20194
704/01/20193
2105/01/20195
1406/01/20193
1307/01/20192
1908/01/20194
2009/01/20194
710/01/20194
2111/01/20194
1412/01/20193
1313/01/20194
1914/01/20196
2015/01/20195
716/01/20195
2117/01/20195
1418/01/20196
1319/01/20193
1920/01/20193
2021/01/20193
722/01/20195
2123/01/20196
1424/01/20195
1325/01/20195
1926/01/20195
2027/01/20195
728/01/20194
2129/01/20193
1430/01/20193

 

Could anyone help? Thanks 🙂

3 Replies
Channa
Specialist III
Specialist III

use left join 

 

Channa
FilippoValli
Contributor III
Contributor III
Author

Thank you for the reply, I'm sorry could you please explain? What should I do after left Join?

FilippoValli
Contributor III
Contributor III
Author

I tried making a left join but for some reason it's giving me error : "There is no open data connection"

Is it because I'm loading data from an excell file? How could I adress this problem?

 

Attached my code:

 

Set dataManagerTables = '','Foglio1','Foglio1-1';
//This block renames script tables from non generated section which conflict with the names of managed tables

For each name in $(dataManagerTables)
    Let index = 0;
    Let currentName = name;
    Let tableNumber = TableNumber(name);
    Let matches = 0;
    Do while not IsNull(tableNumber) or (index > 0 and matches > 0)
        index = index + 1;
        currentName = name & '-' & index;
        tableNumber = TableNumber(currentName)
        matches = Match('$(currentName)', $(dataManagerTables));
    Loop
    If index > 0 then
            Rename Table '$(name)' to '$(currentName)';
    EndIf;
Next;
Set dataManagerTables = ;


Unqualify *;

[Foglio1_ce09410f-dd83-8c66-0da8-3c5b5f99]:
Hierarchy(NodeId,ParentId,Mu_Descr_Device)LOAD
 [Mu_Descr_Device],
 [Mu_Load],
 [Mu_Tipo_Vettore],
 [Mu_Gateway],
 [Mu_Device] AS [Mi_Device-Mu_Device],
 [NodeId],
 [ParentId]
 FROM [lib://Prova/PROVA.xlsx]
(ooxml, embedded labels, table is Foglio1);

[Foglio1_bd219530-b258-4479-e695-15cbf137]:
LOAD
 [Mi_Device] AS [Mi_Device-Mu_Device],
 [Mi_Date],
 [Mi_Measure]
 FROM [lib://Prova/PROVA2.xlsx]
(ooxml, embedded labels, table is Foglio1);


RENAME TABLE [Foglio1_ce09410f-dd83-8c66-0da8-3c5b5f99] to [Foglio1];

RENAME TABLE [Foglio1_bd219530-b258-4479-e695-15cbf137] to [Foglio1-1];


[autoCalendar]:
  DECLARE FIELD DEFINITION Tagged ('$date')
FIELDS
  Dual(Year($1), YearStart($1)) AS [Year] Tagged ('$axis', '$year'),
  Dual('Q'&Num(Ceil(Num(Month($1))/3)),Num(Ceil(NUM(Month($1))/3),00)) AS [Quarter] Tagged ('$quarter', '$cyclic'),
  Dual(Year($1)&'-Q'&Num(Ceil(Num(Month($1))/3)),QuarterStart($1)) AS [YearQuarter] Tagged ('$yearquarter', '$qualified'),
  Dual('Q'&Num(Ceil(Num(Month($1))/3)),QuarterStart($1)) AS [_YearQuarter] Tagged ('$yearquarter', '$hidden', '$simplified'),
  Month($1) AS [Month] Tagged ('$month', '$cyclic'),
  Dual(Year($1)&'-'&Month($1), monthstart($1)) AS [YearMonth] Tagged ('$axis', '$yearmonth', '$qualified'),
  Dual(Month($1), monthstart($1)) AS [_YearMonth] Tagged ('$axis', '$yearmonth', '$simplified', '$hidden'),
  Dual('W'&Num(Week($1),00), Num(Week($1),00)) AS [Week] Tagged ('$weeknumber', '$cyclic'),
  Date(Floor($1)) AS [Date] Tagged ('$axis', '$date', '$qualified'),
  Date(Floor($1), 'D') AS [_Date] Tagged ('$axis', '$date', '$hidden', '$simplified'),
  If (DayNumberOfYear($1) <= DayNumberOfYear(Today()), 1, 0) AS [InYTD] ,
  Year(Today())-Year($1) AS [YearsAgo] ,
  If (DayNumberOfQuarter($1) <= DayNumberOfQuarter(Today()),1,0) AS [InQTD] ,
  4*Year(Today())+Ceil(Month(Today())/3)-4*Year($1)-Ceil(Month($1)/3) AS [QuartersAgo] ,
  Ceil(Month(Today())/3)-Ceil(Month($1)/3) AS [QuarterRelNo] ,
  If(Day($1)<=Day(Today()),1,0) AS [InMTD] ,
  12*Year(Today())+Month(Today())-12*Year($1)-Month($1) AS [MonthsAgo] ,
  Month(Today())-Month($1) AS [MonthRelNo] ,
  If(WeekDay($1)<=WeekDay(Today()),1,0) AS [InWTD] ,
  (WeekStart(Today())-WeekStart($1))/7 AS [WeeksAgo] ,
  Week(Today())-Week($1) AS [WeekRelNo] ;

DERIVE FIELDS FROM FIELDS [Mi_Date] USING [autoCalendar] ;

 


jTable:
SELECT * from Foglio1;
Left Join Select * from Foglio1-1;