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: 
risabhroy_03
Partner - Creator II
Partner - Creator II

Summation of two if conditions

I have two different measures 

if([Invoice_Date_GMT_Updated]=date(max(total <[Company_Code]> [Invoice_Date_GMT_Updated])),

sum(Quantity),

null()

)

And the second one 

 

if([As_On_Date_GMT_Updated]=date(max(total <[Company_Code]> [As_On_Date_GMT_Updated])),

sum(Quantity),

null()

)

Both individually gives correct values, but I want both of them in a single column.

I have to create both of them in the front end visualization only.

How is that possible.

9 Replies
Or
MVP
MVP

You could just add them with a plus, though you'd likely have to replace the null() with 0 because null + any number = null.

risabhroy_03
Partner - Creator II
Partner - Creator II
Author

I tried but my sum is coming as 0

Or
MVP
MVP

Sorry, no idea what else to suggest without a sample app since I can't tell what those expressions actually mean and what context they're working under. One other thing, you could RangeSum() them instead of using straight addition, which is cleaner because it'll deal with the nulls better.

risabhroy_03
Partner - Creator II
Partner - Creator II
Author

My actual need is this 

 

I have 3 fields below Company Code, NumDate, Weight.

Each company code has multiple dates stored.

risabhroy_03_0-1640084603509.png

 

I want to sum my Weight on the basis of the Maximum Numdate for each company code.

Example - For company code 215, my weight should be on the basis of the maximum NumDate that is 15-12-21.

For Company code 220, my weight should be on the basis of the maximum NumDate that is 17-12-21.

 

Can you help me achieve this?

Or
MVP
MVP

Sounds like you want to look at using Company Code as a dimension, max(NumDate) for the date, and FirstSortedValue() to get the weight.

risabhroy_03
Partner - Creator II
Partner - Creator II
Author

Yes, can you help me write the set expression?

I tried but it didn't work as expected.

Or
MVP
MVP

If you tried, you should post what you already did, and perhaps I (or someone else) can help fix it.

risabhroy_03
Partner - Creator II
Partner - Creator II
Author

I tried this adding this in my measure

if([NumDate]=date(max(total <[Company_Code]> [NumDate])),

sum(Weight_Inventory3),

null()

)

 

But i want to achieve this using set analysis

Or
MVP
MVP

This doesn't look anything like what I suggested... and it looks like you opened a thread for this question so I'll let that one play out.