Qlik Community

Ask a Question

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Do More with Qlik - for Beginners and Beyond, Topic: Qlik Replicate on January 21, 2PM EST. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Creator II
Creator II

Adding two values with respect to date conditions at backed script

Hello everyone,

I am trying to achieve the below:-

If("Calendar Year" <= Year(today()), Actual) + if("Calendar Year" >=year(today()), RB) as Hours

 

Is this correct to calculate the dimension at backend.

 

I want to create a dimension "Hours" using this conditon

Hours = “actual” hours when Year < Today + “RB” hours when Year >= Today

 

Pleas help

Labels (3)
2 Solutions

Accepted Solutions
MVP
MVP

Assuming that you have all column in same table then try below in script You can then use the hour as a dimension

If("Calendar Year" <= Year(today()), Actual, RB) as Hours

View solution in original post

Not entirely sure, but may be this

RangeSum(
If("Calendar Year" < Year(Today()), Actual),
If("Calendar Year" > Year(Today()), RB)
) as Hours,

But what happens when Calendar year = Year(Today())? Right now both you are if statements don't include that condition. You might want to change one of the if statement logic to include =, either >= or <= depending on the value needed for current year

View solution in original post

9 Replies
Master II
Master II

can you share a sample data and if possible the expected output ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
MVP
MVP

You an create a Flag in script and then you can use it to create the measure

LOAD *,

if("Calendar Year" <= Year(today()), 1,2)  as Year_Flag

FROM Source;

then you can use below measure in chart

=sum({<Year_Flag={1}>}Actual)+sum({<Year_Flag={2}>}RB)

Creator II
Creator II

@Taoufiq_Zarra 

Please see the data:-

Aspiring_Developer_0-1598440667825.png

LOAD

Actual,
If("Calendar Year" < Year(today()), Actual)  + if("Calendar Year" > year(today()), RB) as Hours,
CB,
"CB - Unit",
RB

From....

Please help as i have deliver it next week

 

 

Creator II
Creator II

@Kush 

 

Mnay thanks Kush for your response.

But i have to create a dimension  as "Hours" using this calculation at the backend. Could you please help me on that.

 

Many thanks again

MVP
MVP

Assuming that you have all column in same table then try below in script You can then use the hour as a dimension

If("Calendar Year" <= Year(today()), Actual, RB) as Hours

View solution in original post

Creator II
Creator II

@Kush 

Hello Kush , i wish to achieve this:

Hours = “actual” hours when Yearmonth < Today + “RB” hours when Yearmonth >= Today

We have to add them at the backend and display them as "Hours" in dimension.

 

Thanks

Creator II
Creator II

Can anyone please help on this as it is very critical for me and i tried everything but not working.

 

@sunny_talwar 

MVP
MVP

It's really not clear what you are trying to do. did you check my last response?

Not entirely sure, but may be this

RangeSum(
If("Calendar Year" < Year(Today()), Actual),
If("Calendar Year" > Year(Today()), RB)
) as Hours,

But what happens when Calendar year = Year(Today())? Right now both you are if statements don't include that condition. You might want to change one of the if statement logic to include =, either >= or <= depending on the value needed for current year

View solution in original post