Qlikview: tablebox or straight/pivot which would show minimum value and related value of the min value

冷暖自知 提交于 2019-12-12 02:31:42

问题


This is driving me nuts. Say I have a mass of lists with product names, their prices and the origins of the pricing: Product, 1$, USA Product, 2€, EU Product, 0.5€, HK

What is the correct table configuration to get this result, without duplicating the record of the same product name?: Product 0.5€ HK

That is to say the table calculates the minimum price and shows the correct origin for the minimum price?

I either get all expanded pivot dupe products or the product origin is returned bogus. Excel's pivot does not show duplicate rows, and the simple index and match functions work fast, but I want the two calculations to be done within Qlikview with success.

Please help, -v


回答1:


You need to do this in the scripting portion of the app.

First you need to build a list of the Products and their minimum prices

 LOWEST_PRICES:
 Load Product_ID, 
      min(Selling_Price) as Min_Price
 resident SOURCE_TABLE
 group by Product_ID;

and then you are going to use that combination of the minimum price and the product_ID to join back source location onto the table

left join
Load Product_ID,
     Selling_Price as Min_Price,
     Source_Location
Resident SOURCE_TABLE;

Then you can just let QlikView associate to the Product_ID from the original table and it'll always return one Source_Location and one Min_Price




回答2:


To anyone thinking of a solution - here's a modified version (major credit goes to TheBudac) to actually get more than what I was asking in the first place. This is a step up in actually giving me the minimum as well as the maximum pricing and both of the origins of the prices in question; modifying the left join ORIGIN field to become unique was the key to actually get more than one answer from my data; ENJOY!:

**

LOWESTPRICES:
LOAD EAN,
     min(PRICE) as MINEUR
resident ALL
group by EAN;
left join
LOAD EAN,
     PRICE as MINEUR,
     ORIGIN as MINORIGIN
Resident ALL;
HIGHESTPRICES:
LOAD EAN,
     max(PRICE) as MAXEUR
resident ALL
group by EAN;
left join
LOAD EAN,
     PRICE as MAXEUR,
     ORIGIN as MAXORIGIN
resident ALL;
//BRAND AND NAMES
LOAD EAN,
     ESSBRAND,
     ESSNAME

**




回答3:


You should normalize your data in a structure like this:

PRODUCTS_TABLE
-description
-price
-id_origin (FK)

ORIGINS_TABLE
-id
-country

id and id_origin are linked (FK is foreign key, id is the primary key). Your initial data should be splitted and fit into this kind of structure. Then you should easily build your pivot.



来源:https://stackoverflow.com/questions/43307464/qlikview-tablebox-or-straight-pivot-which-would-show-minimum-value-and-related

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!