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

Calculate current month YTD minus previous month YTD

Hello,

I have the table as shown below with YTD and MTD as expressions. 1.PNG

MTD = (Current month YTD) - (Previous month YTD).

My expression for MTD = YTD - Alt(Above(Total(YTD)), 0).

This expression is calculating correctly when selecting individual project number, but for all the project numbers selected It is calculating on per row basis which is completely wrong as shown in the below image;


Capture.PNG


Any idea on how to avoid it? (I want to calculate MTD as current month YTD - previous month YTD per Project_Number)


attached are files for your reference;

thanks


30 Replies
sunny_talwar

I guess I get your point. You will need to ignore selection in Snapshot_Date, MonthYear or any other date and time field where you are making selection and then multiply your whole expression with Avg(1).

sunny_talwar

Here is your example.... didn't need to multiply by Avg(1) because we were using Aggr(). But other than that you have unnecessarily made your expression super complicated... why do you need Num() function 20 times (exaggerated, but you get the point). Try the remove unnecessary functions to make your expression easier to understand

Capture.PNG

bhaveshp90
Creator III
Creator III
Author

stalwar1‌ thank you So much for it. I tried to put in my application but something is failing out. Can you tell me where I am doing wrong? Attached is for your reference. thank you

sunny_talwar

I tried to put in my application but something is failing out. Can you tell me where I am doing wrong?

Hahahaha do you want to may be tell me what is failing out? I am not 'Antaryami' brother

bhaveshp90
Creator III
Creator III
Author

Sorry if you felt wrong for my saying. I am trying and couldn't able to find out what's is wrong. But your solution is exactly what I want. thank you again.

sunny_talwar

Hey what happened bhaveshp90‌? I was just asking about that is not right in the new attachment brother? You didn't like my comment? I was just trying to add humor.

Anyways I am sorry if you feel offended.

Best,

Sunny

bhaveshp90
Creator III
Creator III
Author

Not like that brother. I am thinking you might feel bad for what I have asked you. I didn't feel offended. I agree that it is not correct to ask like that.

You need not be sorry stalwar1‌. I thank you for your solution and quick response every time.

bhaveshp90
Creator III
Creator III
Author

See, I like your comment too

sunny_talwar

There is no reason for me to feel bad about anything you ask. Once again, my question to you was -> What makes you think that the file you attached is not working? Can you give me an example where you see issues? All I was trying to say was that without you giving me this information, it is hard (time consuming and hence less efficient) for me to go in and try to figure out what isn't working the way it should. But if you can tell me, I can quickly go in and check to see what the issue is and how we can resolve it.

Does that make sense?

no hard feelings at all

bhaveshp90
Creator III
Creator III
Author

Yes, I understand. When I use the same expression in my application the for MTD it is not working. Look at how the values are; Can you look into this expression for MTD?

1.PNG