Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
woshua5550
Creator III
Creator III

Need a set analysis expression

Hi everybody,

I have 2 tables like this 

Table1Table1

2.PNG

RelationshipRelationship

All I want to do is to create a straight table with Model and ReportMonth dimension, and count the number of VIN1/VIN2 for each Model when WSMonth = ReportMonth

expect result :

ModelReportMonthCount VIN1Count VIN2
A20190110
B20190111
B20190211

 

what should my expression looks like ?

Thanks !

Dave

Labels (2)
1 Solution

Accepted Solutions
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

If join is not a good option, perhaps concatenating both tables will solve the problem:

clipboard_image_0.png

Refer qvw attached below as reference.

 

Thanks and regards,

Arthur Fong

View solution in original post

4 Replies
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

Try joining these 2 tables together:

clipboard_image_0.png

Remove the set analysis at the second expression.

Refer script as below:

LOAD * Inline [
Model,ReportMonth,VIN1
A,201901,V1
B,201901,V2
B,201902,V3
];
JOIN
LOAD Model,WSMonth AS ReportMonth,VIN2 Inline [
Model,WSMonth,VIN2
B,201901,V4
B,201902,V5
];

 

Thanks and regards,

Arthur Fong

woshua5550
Creator III
Creator III
Author

Hi Arthur 

Thanks, but I'm afraid we can't do the join because the 2 tables stands for different business meanings, you can consider that table1 is stock information and table2 is sales information

calculation goes wrong  when table2 becomes like this :

Capture.PNG

expected result :

ModelReportMonthCount VIN1Count VIN2
A20190110
B20190112
B20190211

 

BRs

Dave

Arthur_Fong
Partner - Specialist III
Partner - Specialist III

If join is not a good option, perhaps concatenating both tables will solve the problem:

clipboard_image_0.png

Refer qvw attached below as reference.

 

Thanks and regards,

Arthur Fong

jaibau1993
Partner - Creator III
Partner - Creator III

Hi! Set analysis is evaluated once per chart. This means that you can't build a "row-wise set analysis" expression but it is what you need: for each value of the dimension "ReportMonth" you need to count VIN2 where WSMonth equals the respective value of ReportMonth. Said so and given that you can not modify the script (by the way, are you sure you cant? You dont neet to join nor concatenate both tables, you maybe can create an auxiliar field that helps you solve your problem) I suggest you to use an "if" expression:

Count(if(WSMonth = ReportMonth, VIN2))

since it is row wise (but it is less efficient than set analysis so be careful).

Regards,

Jaime.