Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello ,
I have measurement points with references, name and rate.
I want to create entry points from these points
example:
Ref | name | Rate
1 | place H | 100
2 | YY Street | 120
I want to create an entry point that will be 1 + 2 and named 'AAAA' and keep other references
and calculate the average rates for the new entry point.
Thank you.
Hey there,
Please use this code:
LOAD @1 as Ref,
@2 as name,
@3 as Rate
FROM
[C:\Users\Administrator\Desktop\Data.txt]
(txt, codepage is 1252, explicit labels, delimiter is '|', no eof, filters(
Remove(Row, Pos(Top, 1))
));
LOAD
3 as Ref,
'AAAA' as name,
Sum(if(Ref = 1, Rate, 0) + if(Ref = 2, Rate, 0)) as Rate
Resident Data;
You'll get something like this:
See the Data.txt and qv1.qvw in the Example.zip attached file.
Best regards,
MB
Then you I would change my original code to this:
Let vRef = 3;
Let vName = 'AAAA';
Let vDate = '12/12/2019';
LOAD @1 as Ref,
@2 as name,
@3 as Date,
@4 as Rate
FROM
[C:\Users\Administrator\Desktop\Data.txt]
(txt, codepage is 1252, explicit labels, delimiter is '|', no eof, filters(
Remove(Row, Pos(Top, 1))
));
LOAD
'$(vRef)' as Ref,
'$(vName)' as name,
Date('$(vDate)') as Date,
Sum(if(Ref = 1, Rate, 0) + if(Ref = 2, Rate, 0)) as Rate
Resident Data;
Which will give you this result:
See the Example.zip attached.
Maybe you need a maximum date to aggregate the two records dates? Like this:
Let vRef = 3;
Let vName = 'AAAA';
LOAD @1 as Ref,
@2 as name,
@3 as Date,
@4 as Rate
FROM
[C:\Users\Administrator\Desktop\Data.txt]
(txt, codepage is 1252, explicit labels, delimiter is '|', no eof, filters(
Remove(Row, Pos(Top, 1))
));
TempMaxExpNr:
Load Max(Date) as MaxDate resident Data;
Let vDate = Peek('MaxDate');
Drop Table TempMaxExpNr;
LOAD
'$(vRef)' as Ref,
'$(vName)' as name,
Date('$(vDate)') as Date,
Sum(if(Ref = 1, Rate, 0) + if(Ref = 2, Rate, 0)) as Rate
Resident Data;
The result should be like this:
See the Example.zip in attached file.
Best regards,
MB
Then it should be something like this:
Let vRef = 3;
Let vName = 'AAAA';
LOAD @1 as Ref,
@2 as name,
@3 as Date,
@4 as Rate
FROM
[C:\Users\Administrator\Desktop\Data.txt]
(txt, codepage is 1252, explicit labels, delimiter is '|', no eof, filters(
Remove(Row, Pos(Top, 1))
));
LOAD
'$(vRef)' as Ref,
'$(vName)' as name,
Date,
Sum(if(Ref = 1, Rate, 0) + if(Ref = 2, Rate, 0) ) as Rate
Resident Data
Group by
Date
;
Look at the final result
Refer to the attached file.
Best Regards,
MB