Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
samwork1
Contributor III
Contributor III

Help to create table with measures coming from columns with same elements

Hi, not sure exactly how to ask this questions but I have the following data:

Client

Region

Type A

Region

Type B

Revenue
AWestWest10
BEastWest20
CEastNorth30
DEastEast40
ESouthSouth50

I would like the following report

Region

Revenue

Type A

Revenue

Type B

North030
West1030
East9040
South5050

Can you help?

Thanks,
Sam.

6 Replies
shraddha_g
Partner - Master III
Partner - Master III

Try:

Dimension : valuelist('North','West','East','South')

Measure 1 - Revenue Type A :-

Pick(wildmatch(valuelist('North','West','East','South'),'North','West','East','South'),

sum({<[Revenue Type A] = {'North'}>}Revenue),

sum({<[Revenue Type A] = {'West'}>}Revenue),

sum({<[Revenue Type A] = {'East'}>}Revenue),

sum({<[Revenue Type A] = {'South'}>}Revenue)

)

Measure 2 - Revenue Type B :-

Pick(wildmatch(valuelist('North','West','East','South'),'North','West','East','South'),

sum({<[Revenue Type B] = {'North'}>}Revenue),

sum({<[Revenue Type B] = {'West'}>}Revenue),

sum({<[Revenue Type B] = {'East'}>}Revenue),

sum({<[Revenue Type B] = {'South'}>}Revenue)

)

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi

I would restructure datamodel by doing following:

TableA:

Load

     Client,

     Region Type A      as Region,

     'A'                          as Type,

     Revenue

From

     YourSource

;

Concatenate(TableA)

Load

     Client,

     Region Type B      as Region,

     'B'                          as Type,

     Revenue

From

     YourSource

;

Then I would just build pivot table with:

Dimension

     Region and Type

Measure

     Sum(Revenue)

hth

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
sohb2015
Contributor III
Contributor III

Hi Sam,

You could do this way also:

    LOAD

         RegionA AS Region,

         Revenue AS RevenueA,

         0 AS RevenueB

      FROM Table;

       Concatenate

      

       LOAD

         RegionB AS Region,

         0 AS RevenueA,

         Revenue AS RevenueB

        FROM Table ;

Then in the tab, you only need to use a pivot chart. Use sum(RevenueA) and sum(RevenueB) in the expression to achieve the format you need.

Capture.JPG

       

   Thnaks

samwork1
Contributor III
Contributor III
Author

Thanks everyone for your response.  My colleague Abhay was able to solve using crosstable - he may have additional comments below.

One more question (I think!)

Now we want to calculate the difference - any suggestions?

Region

Revenue

Type A

Revenue

Type B

Difference

North030-30
West1030-20
East904050
South50500
samwork1
Contributor III
Contributor III
Author

Also FYI wanted to mention we are under a tight time pressure for this so that's why we're trying to avoid making lengthier (but likely better designed) changes.  Its a simple model we are doing.

Thank you again for any help you can provide.

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi

so by using "Crosstable" functionality you got to exactly the same output i was suggesting.

once you have this structure in order to deduct A-B you have to do following:

  • Create a straight table chart
  • Use dimension region
  • use Expression Sum({<Type = {A}>} Revenue)-Sum({<Type={B}>}Revenue)

This would work if you would keep namings from my previous posts.

cheers

Lech

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.