qlikview table filter forcing wrong filter - sql-server

Using qlikview 8 personnel edition.
On my main tab i have a chart that concats year and period (year and month) from this I use it as a filter to select periods, this works fine except when trying to select multiple years and periods, it allows selection but say:
Select all from year 2013, and up to year 2014 month 09. It actually selects all from 2013 and 2014.
why would it be doing this?
Some details:
=Num#(If(Len(Year & Period)=5,Year & '0' & Period, Year & Period))
outputs "201301" etc
Like I said i can select whatever month upto a month i want withing a year. However doing the same over multiple years forces it to select all months.

Because the year & month columns are separate in your model, making the selection that you described actually DID select all of the months. You got them from 2013. It didn't care that you only hoped to limit to 1-9 for 2014.
If possible, move that concatenation to the load script where it can become its own field and then you should be good to go.

Related

Power BI: Week #'s not sorting properly

I am having trouble with a line graph visual, where the data is organized by week number and by year number. However when I put the information into the visual and try viewing both 2020 & 2021, it rearranges the data in the order of 2021 & 2020. How do i get it to properly see the data in the correct order of week number by year?
I tried sorting the week # by an index value, also by year, also by week... with no luck
From the images it looks like there is no sort on the year and week, just by the week.
You need to add a column that has a year week key, that you can sort by.
For example 202101 for the week one of 2021.
Assuming you have a date like dd/mm/yyyy format, for example 11/04/2021 in DAX you can use:
YearWeek = YEAR('Table'[Date]) & WEEKNUM('Table'[Date])
This should now sort the data correctly. If you want you can add another column, that is more user friendly like WK01-2021, if you wish, you can then sort by that column, or use the new key column to sort the textual one.
If you just have a year and week column, create a new column that concatenates the two.
For this you should have a Calendar table, that contains a the date groupings that you you need. For example using CALENDARAUTO or you can do it in Power Query here or here.
This actually does not give the correct sequence, when you are dealing with single digit week numbers. For example when dealing with the first ten weeks of 2020, the sequence would be 20201, 202010,20202, 20203... which is obviously wrong.
Here you need a double digit Week number, so a small change in the suggested formula should do it:
YearWeek = YEAR('Table'[Date]) & FORMAT(WEEKNUM('Table'[Date]),"00")
The sequence should now work.

SQL Server Reports Builder - showing dates of current week (help)

I am using SQL Server Report Builder to generate a weekly report to show the weekdays Monday - Friday and then the relevant dates.
The report pulls the information from a calendar in SharePoint 2016.
Instead I have created 5 columns with static weekdays and the week dates:
The following generates the weekdays:
=IIf(UCase(Format(Fields!Start_Time.Value, "dddd"))="MONDAY",FORMAT(Fields!Start_Time.Value, "h:mm tt ") & FORMAT(Fields!End_Time.Value, "- h:mmtt"),"")
The following generates the week dates:
=FORMAT(Today.addDays(1-weekday(Today,FirstdayOfWeek.Monday)),"dd/MM/yyyy")
Screenshot of the SQL Report
Which means show the date/time of each weekDay otherwise leave blank.
The problem with this approach is that does show all the entries even those of last week ...
The purpose is to show only for current week.
Unfortunately, I am out of ideas and not sure what else can be done?
UPDATE
I have managed to find a way around this :)
The expression needed to be:
=IIf(FORMAT(Fields!Start_Time.Value,"dd/MM/yyyy")=FORMAT(Today.addDays(1-weekday(Today,FirstdayOfWeek.Monday)),"dd/MM/yyyy"),FORMAT(Fields!Start_Time.Value, "h:mmtt ") & FORMAT(Fields!End_Time.Value, "- h:mmtt"),"")

Create a column within an SSRS Report to sum values based on conditions of previous column

I have an ssrs report that shows revenues for each month of a year for several years based on start and end date parameters the user enters. What I would like to do is add a second column that shows the revenue for that quarter (march would show q1 revenue, june q2 etc). the problem I am having is that I am able to do this for a single year but once the query starts looking at multiple years my column shows the value for all 1st quarters regardless of year. The picture shows what I am currently getting. Any recommendations on how to fix my expression to also look at the year value when summing these quarters?
Here is the code I am using to only populate the quarter column based on the month.
=IIF(Fields!Sort_Order.Value=3,
Sum(Lookup(1,Fields!Sort_Order.Value,Fields!Calculated_Revenue.Value,"Bookings"))
+Sum(Lookup(2,Fields!Sort_Order.Value,Fields!Calculated_Revenue.Value,"Bookings"))
+Sum(Lookup(3,Fields!Sort_Order.Value,Fields!Calculated_Revenue.Value,"Bookings")),
IIF(Fields!Sort_Order.Value=6,
Sum(Lookup(4,Fields!Sort_Order.Value,Fields!Calculated_Revenue.Value,"Bookings"))
+Sum(Lookup(5,Fields!Sort_Order.Value,Fields!Calculated_Revenue.Value,"Bookings"))
+Sum(Lookup(6,Fields!Sort_Order.Value,Fields!Calculated_Revenue.Value,"Bookings")),
IIF(Fields!Sort_Order.Value=9,
Sum(Lookup(7,Fields!Sort_Order.Value,Fields!Calculated_Revenue.Value,"Bookings"))
+Sum(Lookup(8,Fields!Sort_Order.Value,Fields!Calculated_Revenue.Value,"Bookings"))
+Sum(Lookup(9,Fields!Sort_Order.Value,Fields!Calculated_Revenue.Value,"Bookings")),
IIF(Fields!Sort_Order.Value=12,
Sum(Lookup(10,Fields!Sort_Order.Value,Fields!Calculated_Revenue.Value,"Bookings"))
+Sum(Lookup(11,Fields!Sort_Order.Value,Fields!Calculated_Revenue.Value,"Bookings"))
+Sum(Lookup(12,Fields!Sort_Order.Value,Fields!Calculated_Revenue.Value,"Bookings")),""))))
I ended up creating a quarter column within my data set that was then used as a parent group for the month rows. I then hid that column and added a total for the quarter that gave me sub totals. Not exactly what I was looking for but gave me the result I needed.

SSRS using Subtract Function in Filters

I am creating a report that shows the performance on a monthly basis.I have historic data from 200101. When I create and preview the report all data shows from 200101 to most recent month.
I want to limit the number of months to be the most recent 13 months.
I tried using this expression
=max(Fields!month.Value)-13
This doesn't work and shows an error.
What about a DATEADD() function? (If I'm understanding your question)
=DATEADD(DateInterval.Month,-13,MAX(Fields!Month.Value))
Other option would be to filter the data out either in SSRS or your SQL.
The SSRS filter would use between TODAY and the DATEADD() function (=DATEADD(DateInterval.Month,-13,TODAY))
Or filter in your SQL:
WHERE Month BETWEEN SELECT DATEADD(MONTH,-13,GETDATE()) AND GETDATE
Ideally your expression should be
=max(Fields!month.Value-100-IFF(Fields!month.Value%100>1,1,88))
100 is for 1 year and 1 is for the month; 88 is actually 100-12 for the case when month is like 201701, then you'd need your value to be 201512 (going back 13 months)
For more checks, we do need to check that we do have 13 month data starting from 200101
=IFF(Fields!month.Value>200201,max(Fields!month.Value-100-IFF(Fields!month.Value%100>1,1,88)),200101)

SSRS BIDS 2008 Parameter Date Range

I have produced a report where the user will need to view financial years data.
So for example April 2010 - March 2011 will have one years data however if the user selects this as in my image, data for January, February, March in 2010 will be brought as well as January, Febrary and March 2011, when I dont want the Jan,Feb,Mar for 2010 as the financial year begins in April.
I therfore need to be able select a data range using parameters to stop bringing data through that I didnt ask for.
Can anyone advise me how to do this?
You can build a month-year key to use instead of your ad-hoc year and month parameters. You can then display it for example as YYYY/MM - so that you can select 2010/04 through 2011/03.
Another option would be to have from month (with year) to month (with year).
Yet another option would be to have a year, month, and number-of-months, selecting 2010, 04, then 12 for number-of-months.
Your two parameters aren't aware of eachother in the way that you want it to be.

Resources