Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Manage Conditional Expressions

Hi,
I have a straight table with the below 3 columns loaded from SQL:

COSTBILL DAYALERT DATE
102025-MAY
20826-MAY
302520-MAY

I want to add additional 3 columns in the STRAIGHT table. Could you please let me know how this can be achieved?

COSTBILL DAYALERT DATENEXT BILL DATEDAYS FROM ALERT TO NEXT BILL + 5TOTAL
102025-MAY20-JUN31310
20826-MAY8-JUN18360
302520-MAY25-MAY10300

the logic for NEXT BILL DATE should be based on BILL DAY and ALERT DATE.

For Ex:

If bill day is 20 and alert is on 25th of month, then bill day for next month should be populated(Example 1)

If bill day is 25 and alert is before that, then next bill date would be for current month(Example 3)

Days from Alert to Next bill should be:

COLUMN4 - COLUMN3 +5

Total will be :

COLUMN5*COLUMN1

Could you please let me know how to implement the above?

Thanks

Taher

1 Reply
vishsaggi
Champion III
Champion III

Try this?

BillDay:

LOAD *, Day(NextBillDateID - ALERTDtID) + 6 AS DaysToNextBill,

        (Day(NextBillDateID - ALERTDtID) + 6) * COST AS Total;

LOAD *, Date(ALERTDtID, 'DD-MMM') AS DayMonth,

        IF(Day(ALERTDtID) >=25, Date(MonthEnd(ALERTDtID) + BILLDAY),

                                Date(ALERTDtID + (BILLDAY - Day(ALERTDtID)))) AS NextBillDateID,

                               

        IF(Day(ALERTDtID) >=25, Date(MonthEnd(ALERTDtID) + BILLDAY,'DD-MMM'),

                                Date(ALERTDtID + (BILLDAY - Day(ALERTDtID)), 'DD-MMM')) AS NextBillDate;

LOAD *, MakeDate(Year(Today()), Month(Date#(ALERTDATE, 'DD-MMM')), Left(ALERTDATE,2)) AS ALERTDtID INLINE [

COST, BILLDAY, ALERTDATE

10, 20, 25-MAY

20, 8, 26-MAY

30, 25, 20-MAY

];