Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
khasimvali85
Creator II
Creator II

how to create calculated dimensions creation?

Hi,

Can anybody give idea about calculate dimensions

how to create calculated dimension with date field like given below

i have date field like

date

jan-14, feb-14, mar-14 up to current month aug-15

my requirement is in bar chart dimensions like given attachment

current month , previous month and last year current month

Regards,

khasim.

14 Replies
marcus_sommer

This will be helpful: Calculated Dimensions.

- Marcus

Not applicable

Hi

Please find attachment

jonathandienst
Partner - Champion III
Partner - Champion III

I would not use calculated dimensions for this. I would create a selectable date range field. A script like this will add date ranges to the model which you can use in set expressions.

  • First, the script:

Let zToday = Today(1);

Ranges:

LOAD Range, Date(Evaluate(RangeStart)) As RangeStart, Date(Evaluate(RangeEnd)) As RangeEnd;

LOAD * INLINE [

Range; RangeStart; RangeEnd

Today; zToday; DayEnd(zToday)

Yesterday; zToday-1; DayEnd(zToday-1)

This Week; WeekStart(zToday); WeekEnd(zToday)

Last Week; WeekStart(zToday,-1); WeekEnd(zToday, -1)

Last 2 Weeks; WeekStart(today(1),-1); WeekEnd(zToday)

This Month; MonthStart(zToday); MonthEnd(zToday)

Last Month; MonthStart(zToday,-1); MonthEnd(zToday,-1)

This Month Last Year; MonthStart(zToday,-12); MonthEnd(zToday, -12)

Last Month Last Year; MonthStart(zToday,-13); MonthEnd(zToday, -13)

Last Two Months; MonthStart(zToday,-1);  MonthEnd(zToday)

This Year; YearStart(zToday); YearEnd(zToday)

Last Year; YearStart(zToday,-1); YearEnd(zToday,-1)

YTD; YearStart(zToday); DayEnd(zToday-1)

Last YTD; YearStart(zToday,-1); AddYears(DayEnd(zToday-1), -1)

MTD; MonthStart(zToday); DayEnd(zToday - 1)

Last MTD; MonthStart(zToday, -1); AddMonths(DayEnd(zToday-1), -1)

Last Year MTD; MonthStart(zToday, -12); AddMonths(DayEnd(zToday-1), -12)

] (delimiter is ';');

JOIN (Ranges) IntervalMatch (CalDate) LOAD RangeStart, RangeEnd RESIDENT Ranges;

DROP FIELDS RangeStart, RangeEnd;

The last step joins the ranges to your calendar. Replace CalDate in this line with the name of your calendar date field.

  • Now use the ranges in the front end

=Sum({<Range = {'Yesterday'}>} Sales)

=Count(<Range = {'Last Month'}>} distinct EmployeeID)

=Avg({<Range = {'MTD'}>} Receipt)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
sorrakis01
Specialist
Specialist

Hi,

I would not use calculated dimensions for this.


I would create a 3 set analysis expresions to resolve your problem.


1 exp: Sum(Value) (Month selected)


2 exp: Sum(Value) of previous Month


3 exp: Sum (Value) of Last Year Month


Regards

qlikmsg4u
Specialist
Specialist

It is better to create set analysis expressions rather than calculated dimensions.

Kushal_Chawda

Please see the attached.

By default it will display data for current month. You can select the any other month to get the data as required

antoniotiman
Master III
Master III

Hi,

Dimension :

MonthName(Date)

Expression :

=Sum({<Date={">=$(=MonthStart(Max(Date),-1))<=$(=Max(Date))"}+

{">=$(=MonthStart(Max(Date),-12))<=$(=MonthEnd(Max(Date),-12))"}>} Value)

This also works if You have several dates per Month.

khasimvali85
Creator II
Creator II
Author

Hi,

Thanks for reply

already i have date field  date or Month Year

i need condition in dimension using month year.

this one also helpful but not my exact output

Thanks,

Khasim.

khasimvali85
Creator II
Creator II
Author

Hi,

thanks for reply but not like that

the default change the month automatically change the month year and

these values used as dimension

as per given data Last year Current month year(July-14), Previous month year(June-15)) and Current month year(July-15)