Set analysis Qlik sense - Set analysis - Date beetween last month of last year and current month of the year - expression

i have a column which name "Period" and i have last 18 months ( janvier 2021 to novembre 2022)
In my graph i want show only month december 2021 to novembre 2022. I would like to show months beetwen last month of the year and current month.
Thanks in advance for your help :)

You can use set analysis to achieve this:
Sum(
{<[Period] = {">=$(=AddMonths(YearStart(Today()), -1))<=$(=Today())"}>}
[FieldToSum]
)
This set expression works by using:
Numeric search by using the ">=...<=... syntax
Dollar-sign expansion of dates by using the $(=...) syntax
EDIT: See below screenshot

Related

Show value from last day of the given month - SSRS Report Builder

In a Report Builder table I have to show the value from the last day of the given month, when the month is not expanded.
When the month is expanded, the dates have to show the specific value for that day.
Example is January with values 1 to 31 (same as the day numbers):
When January is expanded, it has to show value 1 on Jan 1.... value 15 on Jan 15... value 31 on Jan 31.
When contracted (and the table only show one row for January), it should show the last day's value of 31
Some months do not have values on all days, so the formula just need to take the last value of that given month
When I use the formula "Last()", then it works half of the time, while for some months, the value extracted is the 3rd or 4th last day of the month - do you know what is wrong here?
Hope above makes sense, and thanks for help.
I think I fixed it my self:
Using Last () formula
Learning how to make a sort order in my Union All dataset, so it came out in the right way
How to give points to my self?

Displaying date - three days in long format minus the year in Freemarker

looking for way to display the date in freemarker as "June 1", so long format minus the year. I also need to output the date minus 3 days. So the code that works is
${(.now?long - 259200000)?number_to_date }
but that displays the year as well (June 7, 2021)
I need to get rid of the year.
I figured it out. For anyone who is reading this in the future:
${(.now?long - 259200000)?number_to_date?string['MMMM dd']}
prints as
Current date, minus 3 days, without year. So for me rn :
June 7

PowerBi - Show last week (Monday to sunday)

I'm fairly new to powerbi.
I want to be able to use a slicer to show the last week not the last 7 days.
I know you can use de relative week, but that shows the dates from Sunday to Monday.
I've also red that it's not possible to change the slicer settings for this.
Is it possible to archiev this in another way?
This is my date table https://imgur.com/a/dCcfBAZ
You can add a column that calculates last weeks' weeknumber and compares it to the weeknumber of the date in your row. Find the weeknumber for the current datetime (NOW), subtract 1, wrap that in an IF and you get a boolean to slice with:
LastWeek = IF((WEEKNUM(NOW(),2) - 1) = YourTableName[Weeknum],true,false)
Works the same as the relative week slicer option, but with the week starting on Monday.

Retrieve data based on current ISO week and backwards

I have to work with data retrieved and grouped on a weekly basis (ISO week) and my DB is structured on a daily basis (field: DATE). I need to write down a code which is rolling, so that given the current date, it calculate the week and the retrieve data in the previous 3 weeks, too.
So I write in the WHERE clauses:
TO_DATE(TO_CHAR(DATE, 'YYYYWW')) BETWEEN TO_DATE(TO_CHAR(TO_DATE(running_date, 'YYYYMMDD'), 'YYYYWW'), 'YYYYWW')-3 AND TO_DATE(TO_CHAR(TO_DATE(running_date, 'YYYYMMDD'), 'YYYYWW'), 'YYYYWW')
It doesn't seems to work though.
Any suggestions on how to handle the problem?
Thanks a lot!
You have to subtract 21 days when you want to recive the previous 3 weeks. If you subtract 3 then you recive only the last three days.
You need to use 'IW', not 'WW' as the format mask for ISO week. From the Oracle docs:
IW = Week of year (1-52 or 1-53) based on the ISO standard.
WW = Week of year (1-53) where week 1 starts on the first day of the year and
continues to the seventh day of the year.

How do I calulate week of year in Oracle using a non-standard first day of the week?

I have a query that needs to return the "week of year" of a date field but the customer of the query uses a non-standard first day of the week so TO_CHAR with 'IW' isn't returning the expected result. In this case the first day of the week is Saturday and Friday is the seventh day of the week.
With T-SQL I'd use DATEPART and SET DATEFIRST.
What is the Oracle equivalent? The Oracle answers I've found in the google all talk about setting the NLS_TERRITORY like so ALTER SESSION SET NLS_TERRITORY = 'UNITED KINGDOM'; but I'm not seeing where I can pick an arbitrary day (other than perhaps finding a territory that uses Saturday).
IW works with a Monday - Sunday week, so this should get you what you are looking for. Basically, get the week according to the day 2 days from now:
to_char(your_date + 2, 'IW')
Oracle's default week format calculates the week number from the first day of the year instead of the first day of the week.
So if a year starts on 01-jan-2009 and the first day is on Wednesday, the week No. 1 will be from 01-jan-2009 to 08-jan-2009 (wednesday to tuesday).
You can use the "iw" format (and a little tweak) if you need the week range to start from sunday through saturday. http://download-uk.oracle.com/docs/cd/B14117_01/server.101/b10749/ch9sql.htm#CIHGFJEI
Try this code below. I basically use the "IW" format and add a condition to get the week number to start from a given date.. say...01-jul-2008.
select target_date,
to_char(target_date+1,'iw') week_sun_thru_saturday,
to_number(to_char(target_date+1,'iw')) -
to_number(to_char( to_date('10-jul-2008','dd-mon-yyyy')+1,'iw')) week_from_01_jul_2008
from t;
Remember..This code will not give week number 1 from jul1st to jul-07 .unless of course 01-jul-2008 is a sunday ;)

Resources