Ok, I've seen similar questions on here, but nothing exactly the same. I am creating reports based on a cube that reads data from a DW. A lot of the reports tend to be along the lines of Value by Something By Week or Value By Something By Month. Everything seems ok, but the week and month (columns) don't order correctly. Week 10 goes before Week 9, February comes before January, etc. Im very frustrated bc I can't get these things to work correctly.
To add to this, at some point my customer needs to be able to write their own reports against the cube using Reportbuilder 3.0. So, I am reluctant to rely on manually editing the query. SURELY there is some obvious way to do this. In my DimDate I have a weekname that is a varchar, a week that is date, etc. Same for month.
Im missing something obvious here.
Thanks!
The sort order would make sense (varchars are strings {"Week 10", "Week 9"}, and {"February", "January"}) in that they are coming before their respective pair in the examples you've given, assuming an ASCII type of sort on the string values.
There are multiple ways to have ascending sort with strings as column headers (assuming ASCII type sorting on the string field):
Ensure week numbers are two digits in length e.g. "Week 9" would become "Week 09". This will ensure that the week columns are sorted in ascending order (or descending order, which ever is the case).
Add a month number in front of the month name e.g. "01 January", "02 February" -> You will still need two digit month numbers otherwise you will get the same issue you had with week numbers.
Use formatted dates as opposed to strings, as dates will be sorted properly.
Alternatively, if the issue is being caused in the dimension within the cube you can ensure any order by clauses are on keys, and not name fields.
Related
I'm adding data to a spreadsheet and I want to do basic tasks programmatically.
Every time I add a date like 03/01/2022 the month cells updates to "March" with
ARRAYFORMULA(IF(E2:E = "","", TEXT(E2:E,"mmmm")))
So, I'm counting the entries per month like this:
I created a formula to make a sequence, but it'll go infinitely as per the number of rows, I'd like to reset the count when the Month cell is different than the previous one.
=SEQUENCE(ROWS(B2:B))
David, I assume "Month" is in column B and you want the sequence in column A under "No."
Try using this formula in A2:
=arrayformula(if(B2:B="",,countifs(B2:B,B2:B,row(B2:B),"<="&row(B2:B))))
Briefly:
uses the arrayformula so you don't have to copy down the formula
if(B2:B="",, takes care of any blanks
countifs() along with row() does the rest of the magic.
to see the role of row(), try using just countif(B2:B, B2:B). This will give the total number of occurrences of "January. "February", etc.
row() combined with "<="&row() makes sure that the formula counts occurrences above the current row only.
Watch out for year change. All "January" values across different years will be added to the sequence.
Good luck.
The date is in the correct format ie YYYY-MM-DD. If I sort just on date it sorts to correct order however if i sort on another field first with date the second criteria it is sorted correctly on first criteria but the date is sorted by DD first MM second and YYYY last. Out of curiosity I tried the same file in Excel which sorted correctly. Can anyone explain the difference and how to get a correct sort in Calc? Using 2 criteria in Calc does not work. I tried sorting on date first and species second. Date order was correct but species were jumbled.
The data is a spreadsheet download of an online data base where we record squirrel and other species sightings in the forest. The entries are not in date or species order. There are many fields for each entry but I am trying to sort first to species and then each species to be in date order. It is for an animation using Time Manager.
I have re-asked the question with edit because the question was closed, for what reason I don't know.
The sort does work correctly, tried again and all sorted as it should. Tried to reproduce strange date order but can't. Have no idea what went wrong originally.
Given a list of items which have a date as one field, how can I separate one set which have a date in the first few days of the month from those which have a date in the last few days?
The items are gas bills, generally one per month, in a bank statement which relate to each of two separate buildings and need to go into two separate accounts. They were imported from a CSV file.
In practice, the number of lines involved is small, so I've just done it by hand, but the question of how to do it by formula and sort occurred to me, and I neither have nor found an answer.
I hope it is a slightly interesting question.
The function is simply called DAY. You can find it by clicking on the Function Wizard toolbar icon and looking under the Date&Time category.
For example, in cell B1 enter a formula like =DAY(A1) and fill down. Then go to Data -> Sort.
I have a problem with sorting my columns in my matrix by month order. I have read many, many posts on problems where the results are alphabetical but none where it starts at the wrong month.
I am using a calculated field called MonthSort using expression:
=FORMAT(Fields!createdon.Value,"yyyyMM")
And I have then Sorted by MonthSort in the Column Group (Group Properties) Sorting Option.
This is something that I have used frequently and in the past it has always sorted from Jan to Dec correctly. However this time it is sorting from November to October.
In my query I am pulling data with the following WHERE clause and I am wondering if this is affecting the starting month.
AND (createdon BETWEEN '2016/11/25' AND DATEADD(minute, - 1, #EndDate + 1))
Any help would be gratefully appreciated.
Out of curiosity, what happens if you change the sort expression to =FORMAT(Fields!createdon.Value,"MM")
Your sort expression
=FORMAT(Fields!createdon.Value,"yyyyMM")
gets you data in the format 201611, 201612, 201701,... so the sort works correctly.
In Google Spreadsheets I have a column of various dates (these are employee's start dates). I want the cells to be highlighted when today's day is within a week of these employee start dates.
I have already been playing with =(B4-TODAY())>7 but this seems to highlight all the past dates.
If this is not possible, just being able to highlight this month's dates is fine (which is easy to do in Excel but can't seem to figure out in Google Spreadsheets).
Then, once this has been done, I have another column with a drop box selection with DONE, and, PENDING.
I would like to conditionally format it so that when DONE is clicked, the highlighted start dates in this month (or 7 days before the day) are highlighted in a different colour.
So it can easily be seen that in 1 week employees are coming, and when done is clicked, we can see their administrative stuff has been dealt with.
Please try =B1="DONE" for the alternative colour and for the +/-7 days:
=and(A1<today()+7,A1>today()-7)
in that order.
=and(…) is used in one of the formulae because the relevant condition is for a bounded range. When I enter =today() in Google Spreadsheets and change that cell’s format to Number I see 41,845.00. Since one week either side makes up the ‘band’ to which attention is to be drawn the relevant values for CF are everything from and including 41,838 to 41,852.
But for display purposes I switch to one day either side, rather than one week, and leave off 41840 throughout, so today becomes represented by 5, and the reduced range of interest therefore 4 to 6 (both inclusive). Of all the possibilities, any value up to and including 3, and 7 or greater, is to be ignored for CF:
The range of interest is everything less than 7 (green) that is also more than 3 (blue):
For “that is also” Google prefers and. In case of any remaining uncertainty creating your own example with a week either side of 41845 etc may help.