Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

using two expressions as one expression in bar chart

Hi All

i have two expressions in bar chart

=sum({<IsSameMonth={'1'}>}sales)

=sum({<IsRolling6={'1'} ,IsPr={'1'} >}sales)

i want  to convert these two expressions into a single expression is it possible

20 Replies
sunny_talwar

Yes, you should be able to use a synthetic dimension or Island table as dimension and use Pick(Match()) to display both these expression within a single expression

Not applicable
Author

Hi Sunny can u please provide me an example please

i'm struggling with this since the last 1 week and your help will be highly appreciated

sunny_talwar

Hahahahha, John it would be nice if you can provide me with what you have and I can show how it can be done . It will be time consuming for me to create a sample and then even after I do create one, we won't know if it matches your requirement on not. I don't have that sort of time my friend. Please help me help you by providing me a sample where I can help you out.

Best,

Sunny

Anonymous
Not applicable
Author

=sum({<IsSameMonth={'1'}, IsRolling6={'1'} , IsPr={'1'}   >} sales) gives you sum of sales for all three conditions

sum({<IsSameMonth={'1'}>}   + <IsRolling6={'1'}> + <IsPr={'1'}> } sales)  gives common values....

Not applicable
Author

Hi Sunny

My problem started with this and going on

Top two values in current month comparing the same values with previous month

I'm struggling to get this solution

there is a solution in place which fits me

but

1. i'm getting multiple legends for each month i want a single consolidated legend

2. the colour of the bars if the same country is in both the months it should have same colour

please help me out

sunny_talwar

Wow this is from a while ago. I am willing to help John, all I need is a sample (with actual or dummy data), but something to work with

Not applicable
Author

Hi Sunny this is how i have written my code in the data model

a:
LOAD * INLINE [
    Country, Date, Value
    Argentina,Jul2016,650
    Japan,Jul2016,300
    America,Jul2016,200
    Argentina,Jun2016,550
    Japan,Jun2016,200
    America,Jun2016,100
    America,May2016,300
    Argentina,May2016,250
    Japan,May2016,150
    America,Apr2016,200
    Argentina,Apr2016,170
    Japan,Apr2016,210
];

Temp: 

Load  

               min(Date) as minDate,

               max(Date) as maxDate 

Resident keytable; 

 

Let varMinDate = Num(Peek('minDate', 0, 'Temp')); 

Let varMaxDate = Num(Peek('maxDate', 0, 'Temp')); 

DROP Table Temp; 

 

TempCalendar: 

LOAD 

               $(varMinDate) + Iterno()-1 As Num, 

               Date($(varMinDate) + IterNo() - 1) as TempDate 

               AutoGenerate 1 While $(varMinDate) + IterNo() -1 <= $(varMaxDate); 

 

MasterCalendar: 

Load 

               TempDate AS Date, 

               week(TempDate) As Week, 

               Year(TempDate) As Year, 

               Month(TempDate) As Month, 

              

                     

Resident TempCalendar 

Order By TempDate ASC; 

Drop Table TempCalendar;


tmpAsOfCalendar:
Load distinct Month1  Resident MasterCalendar ;

// ======== Cartesian product with itself ========
Join (tmpAsOfCalendar)
Load Month1 as AsOfMonth
  Resident tmpAsOfCalendar ;

// ======== Reload, filter and calculate additional fields ========
[As-Of Calendar]:
Load Month1,
  AsOfMonth,
  -([AsOfMonth]<>[Month1]) as [IsPrev51],
  Round((AsOfMonth-Month1)*12/365.2425) as MonthDiff,
// Date(Date#(MonthYear,'MMMYYYY'),'YYYYMM') as MonthYearq,
  Year(AsOfMonth)-Year(Month1) as YearDiff
  Resident tmpAsOfCalendar
      Where  AsOfMonth >= Month1;

Drop Table tmpAsOfCalendar;

below is my output

and the problem with this is the legend is not worthy if i'm comparing top5 then it is becomoing clumpsy

and the colour of the same countries should be same in different months where as it is not

please help me out

sunny_talwar

Give me some time to digest this and I will try to get back to you as soon as I can.

Not applicable
Author

ok sunny please dont forget