Previous month expression - qlikview

I need help to get a dynamic expression for the previous month (December 2022) compared to the current year's month, January 2023.
Perhaps the attached might provide some more clarity.

Depends on your data format a bit but in general you should be able to use something like:
= sum( {< Month = {"$(=MonthStart(AddMonths(Today(), - 1)))"} >} Sales)
The set analysis will filter the Sales and will be sum only values for which Month is the month start of the previous month (based on Today() function result)

Related

What method can I use to get a different date value for a stored field in my database?

I am working on a project that is asking me to return different date values based on the scenario and I am not quite sure how to write this out. I think that I'm just not understanding how to apply the logic:
PAYFREQ is A then TRANS_DATE is 1st of the Year of COMPEFFDT
PAYFREQ is M then TRANS_DATE is 1st of the Month of COMPEFFDT
PAYFREQ is B then 1st day of the biweekly period ending with COMPEFFDT
PAYFREQ <> A and the only non-zero FIC amount for a calendar year has COMPEFFDT of December 31, then TRANS DATE is 1st of the Year of COMPEFFDT
Can anyone give me at least a base starting point in how to formulate this statement?
Assuming this is in a query, try the SWITCH statement. I'm not sure what you mean by the "1st of year of COMPEFFDT" though.
SELECT SWITCH (
PAYFREQ = "A", "1st of year of COMPEFFDT",
PAYFREQ = "M", "1st of the Month of COMPEFFDT",
...
) AS Result
Also, you should look at the guide for submitted a new question.

Oracle Week Number from a Date

I am brand new to Oracle. I have figured out most of what I need but one field is driving me absolutely crazy. Seems like it should be simple but I think my brain is fried and I just can't get my head around it. I am trying to produce a Sales report. I am doing all kinds of crazy things based on the Invoice Date. The last thing I need to do is to be able to create a Week Number so I can report on weekly sales year vs year. For purposes of this report my fiscal year starts exactly on December 1 (regardless of day of week it falls on) every year. For example, Dec 1-7 will be week 1, etc. I can get the week number using various functions but all of them are based on either calendar year or ISO weeks. How can I easily generate a field that will give me the number of the week since December 1? Thanks so much for your help.
Forget about the default week number formats as that won't work for this specific requirement. I'd probably subtract the previous 1 December from invoice date and divide that by 7. Round down, add 1 and you should be fine.
select floor(
(
trunc(invoiceDate) -
case
-- if December is current month, than use 1st of this month
when to_char(invoiceDate, 'MM') = '12' then trunc(invoiceDate, 'MM')
-- else, use 1st December of previous year
else add_months(trunc(invoiceDate, 'YYYY'), -1)
end
) / 7
) + 1
from dual;

Month-to-Date metric

I have a situation where the metric calculation(Month to Date Sales) is based on the month from the report date filter.
We want the month to date filter to be for the report month and not the current month - in other words, if the user selects 03/10/2015 for the report date, we want the month sales to be the sales for March,
and not the sales for June.
Is there a way to parse the report date to extract the report month into a variable that can be used in the ‘where' clause of the metrics in order to generate the desired results.
Thanks in advance.
I am not entirely sure if this answers your question, but achieving something like this may be possible when using disconnected timeline date filter. Your metric should look like this:
SELECT Sales_metric BY Month/Year (Date) ALL OTHER WHERE Month/Year (Date) = (SELECT MAX(Month/Year (Timeline)) BY ALL OTHER EXCEPT Date (Timeline))
I hope this helps, in case if it doesn't feel free to log a ticket to GoodData Support at support#gooddata.com.

Adding and Updating data by month in Access with Vb.Net

I've been trying to add and update data to a table in MS Access by month. This is so I can calculate any expenditures or sales per month. So if stock for a company were bought in March It would add this to the March expenditure row. And would be kept different from the expenditure in February or April for example.
I am unsure how to do this and how to have my program check the current month and year to see where it should input the data/make a new row for the month.
I know how to write to a database, I'm just not sure how to make my program write to a row in the database that depends on the current month and year
Any help would be greatly appreciated and sorry If this is all long winded or this is an easy fix, its my first post here and I'm a novice when it comes to programming.
In Access, to get the current date you use the date() function. I.E. if you were to do:
SELECT DATE()
the query would return the system date, which, today would be:
26/03/2015
To do math (add or subtract a specified interval) against the date, the syntax, again in Access, is:
DATEADD([Interval],[Number],[Date])
So, if I wanted to add one month to the current date I would write:
DATEADD(m, 1, DATE())
Or conversely, subtract two months from the current date:
DATEADD(m, -2, DATE())

how to summarize sql result, week and month wise in single query

I want to summarize sql query result week wise and month wise at the same time in a grid view. Is this even possible or I am just dreaming?
Requirement:
Show last one month data and next two month's data week wise in the grid.
Example-
If the current month is September then I want to show data from 1st August to 31st October categorized in weeks.
Show the data after the next month of current month in month wise view in the same grid.
Example-
data for month November and December will be shown categorized in month not in weeks.
grid or result should look something like below -
Please suggest something to achieve this
If you want a maintainable solution, use two independent queries, one for weekly aggregation other for monthly. Depending on the input run corresponding query.
I think you must work with group by or group by ... cube
SELECT x , y from <tabel> GROUP BY date_feld( to_char( 'MM' ))
but i don't now your DBMS so i can't give you a exact example for the date handling.