The Months appear randomly on the Bar Chart instead of in an order. How to change the order of data presented in a Vertical Bar Chart? - bar-chart

I have been creating dashboards on QuickSight for a few months now. I am currently trying to create a dashboard that shows how many people have logged in to our App and want to present this by months.
The problem that I have is that QuickSight tends to present the data in a random way and although I can sort this alphabetically, that does not help me. See an example screenshot with sample data; vertical bar chart
As you can see from the screenshot, the months are ordered as Sept, Oct, Aug.
How can I change this to reflect the correct order of months such as Aug, Sept, Oct. I also want to make sure that going forward, whenever I update the data, I can still be able to sort them correctly.
Hope this make sense

I assume that you are seeing this ordering because the fields you are sorting by are textual (varchar, text, etc) and not ordinal (at least numerically). In other words, QuickSight is sorting alphabetically by month name not by month order. Fortunately there are a couple of ways to resolve this.
I don't really know a lot more about your data but the best way to resolve this is to create an actual date field that represents the month (e.g. the first day of the month). Dates are first-class in QuickSight and should sort naturally in the order you're looking for.
If you already have date entries but they're not monthly, you can use truncDate in a calculated field to truncate the dates to the month level then use formatting options to display them as months.
Lastly, if you absolutely had no other options you could parse your existing fields (in the format Mon-YY) to create date fields.
Do do this you would actually most likely want to create multiple calculated fields that culminate as the date, for example:
Make a new calculated field for the month that does something like, assuming your date column is named yourMonthCol
ifelse(
split({yourMonthCol}, '-', 1) == 'Jan', '01',
split({yourMonthCol}, '-', 1) == 'Feb', '02',
...,
split({yourMonthCol}, '-', 1) == 'Nov', '11',
'12'
)
Then you'd need to do something similar for the year
split({yourDateCol}, '0', 2)
Finally, you should be able to get dates by making a calculated field like the following from the created calculated fields
parseDate('01/' + month + '/' + year)
Then you should be able to use that date as described above. That was a mouthful but I hope it helps!

Related

SSRS Matrix columns show currrent month

I'm stuck with a problem in SSRS 2012 that maybe is very simple:
I have a matrix with a group row (employee) and a group column (last 12 months); the values are COUNT(practicesDone) - i.e. the amount of practices worked.
I want the matrix to show an extra column on the right (after all the columns of the months, and clearly outside the column group) with again the number of practices for the current month.
Is it possible to achieve that?
thank you in advance!
You can do this, it's pretty simple.
I have assumed that your dataset contains a column that has a date for each entry and that the data returned only covers 12 months so the same month would not appear for different years. If your data does have multiple years, look at the second expression below.
Right-click your month column and then to "Insert Column --> Outside Group - Right"
Now set the expression for the text box to
=COUNT(IIF(MONTH(Fields!myDateColumn.Value) = MONTH(TODAY()), 1, Nothing))
You could swap COUNT for SUM and it should do the same thing but either will work.
All we are doing here is comparing the all data in scope which, due to the placement of the text box means the scope is the entire rowgroup. Then for all that data, check if the month matches the current month, if it does set it to 1 is not set it to nothing then count/sum all results. Count conveniently ignores 'nothing'.
If you data covers more than 12 months then you can still do this but you'll have to add a bit more to handle years and months like this.
=COUNT(
IIF(
MONTH(Fields!myDateColumn.Value) = MONTH(TODAY())
AND YEAR(Fields!myDateColumn.Value) = YEAR(TODAY()),
1,
Nothing
)
)

Auto populate dates of the week Paginated reports

Good day
I am very very new two paginated reports so forgive me if this is a silly question
I have a report that displays values for Mondays to Fridays based on the date selected from a date picker.
So basically
You select a date (Example 24 Nov) and the following table is displayed based on values pulled from SQL.
Now my question is how do I display the dates of the weekdays too?
So if the date selected is Thursday 24 Nov, in the column headers under the week day names it should give the corresponding date i.e Monday-21/11/2022, Tuesday - 22/11/2022, etc.
Below is a little snippet of the data
So the date picker is based on the ReportingDate column. The rows of the matrix consist of Region and Country and the values are the sum of Monday-Friday.
Any guidance would be greatly appreciated.
Edit: The day names are not obtained via an expression in SSRS. They carry over from the column headers in the data set.
Assuming you have some expression to get the actual day name already, you can leave that bit as it is.
Now, double click the column header "cell"/textbox to get a cursor in there, then click at the end of the existing fields/expression.
Now just put a space in and then right-click and choose "Create Placeholder". The placeholder dialog will appear.
This placeholder acts almost like a separate textbox to you can put whatever you want in there, click the '[fc]' button next to the Value property and then set this to whatever you want, e.g. =Fields!ReportingDate.Value.
Now go to the "number" tab on the same dialog box and set the format to the required date format.
If you want to edit this later, just double click the cell again but this time right-click the placeholder and choose properties.
The other way of doing this would be to add another row to your header and set that to be the date instead but then you have to mess around removing borders etc., sometimes this can be easier if layout is an issue but you have a couple of options at least now.
I managed to figure it out with the help of the following post.
These are the steps I followed
Get the date of the first day of the current week (Sunday's date) using the formula explained in the link
DateAdd("d",1- DatePart("w", CDate(Parameters!ReportingDate.Value)), CDate(Parameters!ReportingDate.Value))
Use DateAdd to add the corresponding number of days to get to a required weekday. That is for Monday add 1, Tuesday add 2,...
DateAdd("d",1,DateAdd("d",1- DatePart("w", CDate(Parameters!ReportingDate.Value)), CDate(Parameters!ReportingDate.Value)))
Format datetime to date and add new line to insert date below day name
="Monday" + Environment.NewLine + FormatDateTime(DateAdd("d",1,DateAdd("d",1- DatePart("w", CDate(Parameters!ReportingDate.Value)), CDate(Parameters!ReportingDate.Value))), DateFormat.ShortDate)

SSRS select parameter month and change par. first and last day of this month

i need to create parameter list of months and then (after select) recalculate two others paramateres in date format ([first day] and [last day]) of this month, can you please help me?
You are querying a database server to generate the list of months, although there's no need to do that. I suggest to rather create a list of months in the report and let the report calculate the month's names, so the language depends on the Language setting of the report (which can be the language configured in the user's browser).
For example, to calculate the Label for the Value 1, use an expression like =MonthName(1).
The Parameters FirstDay and LastDay (or just the values whenever you need them) can be calculated using these expressions:
FirstDay: =DateSerial(Today.Year, Parameters!Month.Value, 1)
LastDay: =DateSerial(Today.Year, Parameters!Month.Value, 1).AddMonths(1).AddDays(-1)

larger value of two different columns where there are nulls

I'm comparing two date columns about bugs, one is resolved bugs and one is closed bugs. I want the larger of the two, but there are null values (when a bug hasnt been resolved or closed yet). How do i take the greater of the two while ignoring nulls values? I saw other solutions, but you have to specify the dates in the code, which i cant do in my data set as its large. the date format is mm/dd/yy hh:mm:ss PM/AM
(GREATEST(dtResolved , dtClosed))
How about this:
GREATEST(COALESCE(dtResolved , dtClosed), COALESCE(dtClosed, dtResolved))
Using this logic, if both dates be not NULL, then you would get the greater of the two. If one be NULL, then you would get non NULL date.
Edit:
the date format is mm/dd/yy hh:mm:ss PM/AM
This sounds like you are storing your dates as text, always a bad idea. To make the above suggestion work, you'll have to convert your text to dates first:
STR_TO_DATE('02/28/2014 09:30:05 AM', '%m/%d/%Y %r')
Here's another example:
GREATEST(COALESCE(UNIX_TIMESTAMP(STR_TO_DATE(dtResolved, '%m/%d/%Y %r')), 0), COALESCE(UNIX_TIMESTAMP(STR_TO_DATE(dtClosed, '%m/%d/%Y %r')), 0))
This code will give you the bigger date in timestamp. The reason is that the GREATEST function will return your date as a string without any space or slashes between year, month or date. So timestamp is a good way to prevent that.
Just in case dtResolved and dtClosed are null and you would compare them, use COALESCE with 0 instead of both value. It will prevent your query from crashes. It will return 0.
Like Tim told you, converting your string date to date object isn't a bad idea. It is always preferable to work with date object for the multiple function that exist.

How do I create a interval of 7 days without 'w','week' or 'WeekOfYear'?

I am trying to sort data by the week it was created. I can not use 'w' in DateAdd, 'week' or 'WeekOfYear' without an error stating that function/expression is inaccessible.
What is the best way to create a substitute expression? I want the expression to group the dates based on the week it was created.
I am trying to replicate this:
http://imgur.com/Pk8YjUv
Based on the expected results you posted in the edition of your question I have reproduced the tablix.
I've used the following dataset:
I am supposing you are going to use a tablix component so I added this one with the following data arrangement.
In the Row Groups panel right click on date group.
In group properties, add a group expression and set this:
=DATEADD("d",7-DATEPART(DateInterval.Weekday,Fields!date.Value),Fields!date.Value)
Also in the tablix you have to set the same expression:
In the columns you want to sum you can use the Sum function or any aggregation function. I've used =Sum(Fields!value.Value) to Sum values within the same week.
This is the result it will preview:
Let me know if this was helpful.