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

LOAD distinct - Question

Hello,

I am trying to load some data from a given csv-file.

Very simlified extract of the data:

Anmerkung 2019-07-02 130844.jpg

I have the following requirements:

* if I filter for claim 4711 amount should be 2 (not 4)
* if I filter for claim 4711 the sum of cost should be 25
* if I filter for unit 10 sum of cost should be 25
* if I count the number of claims it should be 3 (not 4)

I already have the idea that in the LOAD I should use the keyword "distinct" - but I don´t know exactly how to do this.

Can anybody give me hints for the LOAD?

Thank you in advance!

Rainer

 

Labels (2)
1 Solution

Accepted Solutions
lanlizgu
Creator III
Creator III

something like that? What is the logic for unit? I can't understand it

 

Table1:
load
claim,
sum(amount) as amount,
sum(unit) as unit,
sum(cost) as cost
group by claim
;
LOAD * INLINE [
claim, amount, unit, cost
4711, 2, 10, 10
4711, 2, 11, 15
4712, 3, 10, 10
4713, 1, 12, 5
];

View solution in original post

4 Replies
atoz1158
Creator II
Creator II

Hi

No you should not be using DISTINCT with the LOAD statement as you do want to load all the rows in the csv.

When you come to the front end of things in charts and tables you should be using DISTINCT in functions like Sum() and Count().

 

So a count of claims would be Count(DISTINCT claim) and in your example that would return 3.

 

Regards

Adrian

marcus_sommer

Your requirements 1, 2 and 4 might be manageable with a distinct in the load or the UI expressions but not 3. I assume that you need some more logic to prepare all wanted results within a single table and/or to split the task into several tables.

- Marcus

lanlizgu
Creator III
Creator III

something like that? What is the logic for unit? I can't understand it

 

Table1:
load
claim,
sum(amount) as amount,
sum(unit) as unit,
sum(cost) as cost
group by claim
;
LOAD * INLINE [
claim, amount, unit, cost
4711, 2, 10, 10
4711, 2, 11, 15
4712, 3, 10, 10
4713, 1, 12, 5
];

cosmicyes
Contributor III
Contributor III
Author

Wow, thank you all for your very helpful answers.
I think especially the answer of Lanlizgu will lead me to the right direction.
I´ll need some more testing and will mark an answer as solution asap.
But also I guess I´ll have some further questions 😉