Qlikview Replace WeekSeq number with week number - qlikview

I have a master calendar that includes week and weekseq, weekseq is just an autonumber of week and year. I am having an issue with the column labels on a 52 wk report that works of current week back 52 weeks. When i use weekseq as the column header it works out correctly but this header is of no use, Is there a way for me to replace weekseq with week in my column header? I have currently been trying =week(max(WeekSEQ)) for current week but not working out as it should.
Thanks

for sure :
=week(max(WeekSEQ))
is incorrect as WeekSeq is autonumber and week process date or timestamp field only.
So you need to have Date field in your calendar and use it:
=week(max(*date_field*))
(if you don't have date field you can create it but for that I need at least snapshot of your datamodel - you can make screenshot of table viewer which you can access using Ctrl+T)

Related

How to Cast Date to String for Chart with Weekly Groupings in MS Access

I have a simple Access application where I want a chart that shows groupings by weeks from daily records.
I have a query that converts the groups by the week and then displays the week as the first day like this:
WeekBegin: DateAdd("d",-(DatePart("w",[ScoreDate])-1),[ScoreDate])
Thsi gives the Sunday beginning the week correctly. The problem comes when I go to make a chart. The chart Row Source is
SELECT [WeekBegin],Sum([Scores]), (etc...) FROM [query] GROUP BY [WeekBegin];
When I do this the chart treats the bottom axis as a date value and each week is seven days apart making the bars tiny.
I'm sure the date format is the issue because when I make an integer out of the week value it formats how I want:
I can't figure out how to get it to show as a date like "mm/dd" but not treat it as a date and add all those blank days in between. I've tried messing with the axis settings but it doesn't seem to do anything.
Try casting the date as a varchar... use convert to get into whatever display format you want.

map dates in ship week sql

I'm trying to map ship_date to the correct ship_wk (our ship weeks go from Sunday to Saturday) and I'm not sure how to do it.
The table the ship week field pulls from is currently mapping them incorrectly. For example, ship_wk = 42 should show dates 10/14 - 10/20, but is showing 10/21 - 10/27.
I need to create a different ship week field within my query that uses the correct mapping. I've never worked with dates in this capacity. Any suggestions?

SSAS, how to make Dimension Attribute Month only show the months in current year?

In our date dimension, there are Month and Year attributes. Month attribute has set int month_year as key, to avoid duplicate problem, and Month attribute has name like January, February...
Now there is problem, if user drags Year and Month to filter, and would define one year, say 2017, he expect to see Month Attribute in filter only shows 12 month names in 2017. However, Month Attributes shows month names for all years, the names repeating many times.
There is already calendar hierarchy built in this dimension. But the user wants to define filter outside of hierarchy. How to build such Month Attribute in cube? Does some one have any idea about it? Thanks in advance!
The problem has been solved. Just add a new column in date table, say Month_in_current_Year, has the same content as Month column. Add this new column to date dimension as a new attribute. This new attribute works for my purpose. It shows only 12 elements as months in one year. And it slices correct value while setting it to filter. What magic is the cube!

How to get month within a range vb2010

I just don't know how to go about this.
I designed a program that uses MS Access as its database. I have a field for month and year (the field data type is text) where user can register details. The program will register the month and year the user have chosen e.g month= September, year=2011.
My problem now is how to chose a range of data to view by the user using the month and year as a criteria e.g the User may want to view data range from (September 2011 to July 2013).
I couldn't figure out even how to try. Help will be highly appreciated.
Perhaps you could change your application logic to store the month and year as their respective numbers rather than text and change the field data types to numeric.
You could then construct a DateTime object from them, for example September would be 9 and you could use code like the following:
var startDate = new DateTime(year, month, 1); // get year and month as integers from database, uses the first as the date
var endDate = new DateTime(year, month, 10); // change the date but keeps the month and year the same
var endDate2 = startDate.AddMonths(1); // adds 1 month to the date
Alternatively, you could try using a calendar control to allow the user to select two dates instead of building it from a number of fields. Depending on what you are using this could be achieved a number of ways, for example in ASP.Net or WPF you could use two calendar controls and just use their SelectedDate properties as your range.
A range is from a startpoint until an end point. For the startpoint you can add automatically the first of Month. For the endpoint is it more complicated because there is no fix endpoint. What you can do is following:
Write an array that contains for each month the days (e.g. 30 or 31). Except for Febrauary there is a fix pattern.
for Febrauary use the selected year to check is the year a leap year or not. If not add 28, else add 29.
After that create the date string for your SQL:
Startdate 1.9.2011. Do for the entdate the same.
After that, I think you can use the keyword between in your SQL query.
You can assume that everything is entered on the first day of each month. I would pull the information using a query to the database.
select * from [tablename] where DateSerial([colYear], [colMonth], 1) between DateSerial([fromYear], [fromMonth], 1) and DateSerial([toYear], [toMonth], 1)
In this question are some ways to do this:
First. Filter the dates in a range assuming that you use a date like '07-12-2012'
i.e. September 2011 to July 2013
Where DateColumn > '09-01-2011' and DateColumn < '07-31-2013'
OR
Specify a Date and a Year
Where month(DateColumn)='1' and year(DateColumn)='2016'
Note:
There are many ways to do this.
You can Manipulate your statement depending on your desired output.

How to group by week specifying end of week day?

I need to run a report grouped by week. This could be done by using group by week(date) but the client wants to set the day of the week that marks the end of week. So it can be Tuesday, Wednesday etc. How can I work this into a group by query?
The datetime column type is unix timestamp.
The WEEK() function takes an optional second parameter to specify the start of the week:
This function returns the week number for date. The two-argument form of WEEK() enables you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range from 0 to 53 or from 1 to 53.
However, it can only be set to Sunday or Monday.
UPDATE: Further to the comments below, you may want to consider adding a new column to your table to act as a grouping field, based on WEEK(DATE_ADD(date INTERVAL x DAY)), as suggested in the comments. You may want to create triggers to automatically generate this values whenever the date field is updated, and when new rows are inserted. You would then be able to create a usable index on this new field as required.