I'm trying to make a line chart on WebI 4.2 Support Pack 4 Compilation : 14.2.4.2410.
I have an array with my number of order for each month.
+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
| 165 | 221 | 150 | 214 | 105 | 18 | 115 | 15 | 201 | 26 | 102 | 101 |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
For exemple I use this function in my measures changing the month at the end to get my total of orders.
=Number([Id]) In ([Date]) Where (Month(ToDate([Date]; "dd/MM/yy")) ="january")
How can I get a line chart with my months in x-coordinate and my number of orders in y-coordinate ? I think that I'm totally wrong in my method cause I really don't find how to use line chart correctly.
Should I have my months as dimension variables ?
I do not have the right to post pictures yet to illustrate what I want and sorry for my english level.
I believe you are making this more difficult that it needs to be. It seems like you do not have the Month name in your data. So create a variable to get that. If the object containing your date is a Date data type it would look like this...
Month=Month([Date])
If your date is a string you would do something like this...
Month=Month(ToDate([Date]; "dd/MM/yy"))
If you don't have a measure for your number of orders you will need a variable counting them...
Number of Orders=Count(ID)
Then create a table with Month and Number of Orders. Create a custom sort order if you want the months in chronological order. You can easily create a line chart by right-clicking on your table and choosing "Turn Into > Line Chart".
I did this with a Calendar table I have with a count of the number of days in each month in 2019.
Related
I'm trying to generate multiple bar charts for users that transition through different stages. Following is my structure for user_stage_mappings table
+----+----------+---------+------------------+----------------+
| id | stage_id | user_id | stage_start_date | stage_end_date |
+----+----------+---------+------------------+----------------+
| 1 | 1 | 1 | 2017-12-25 | 2018-01-02 |
| 2 | 2 | 1 | 2018-01-02 | 2018-01-05 |
| 3 | 3 | 1 | 2018-02-05 | |
+----+----------+---------+------------------+----------------+
Now I would like to plot 3 individual charts for each stage, starting from 1st Jan 2018 to 7th Jan 2018 (dates can be any range). So the charts would appear something as follows.
Stage 1 Chart :
Show bar with 1 count for 1st and 2nd Jan, as the idea was in Stage 1 during those days, and no bars for the rest of the days.
Stage 2 Chart :
Show bar with 1 count for 2nd to 5th Jan, as the idea was in Stage 2 during those days, and no bars for 1st, 6th & 7th Jan.
Stage 3 Chart :
Show bar with 1 count for 5th to 7th Jan, as the idea was in Stage 3 during those days, Note there is no end date to the last stage indicating the idea is still in Stage 3.
I have reduced the dataset to bare minimum, the actual dataset would have several users at different stages. What would be the most optimal way to write this as mysql query.
I was thinking maybe loop through 1st to the 7th of Jan and with each iteration count the number of users. For example for the 1st of Jan get users where 1st Jan is between stage_start_date and stage_end_date, but somehow this does not feel optimal.
To me it will be easier to just plot the charts via looping. I explain, first get the number of users for each day with:
SELECT DATE(stage_start_date) stage_start_date, count(DISTINCT user_id) NoOfUsers
FROM user_stage_mappings
WHERE stage_start_date BETWEEN STR_TO_DATE('2018-01-01','%Y-%m-%d')
AND STR_TO_DATE('2018-01-07','%Y-%m-%d')
GROUP BY DATE(stage_start_date)
ORDER BY DATE(stage_start_date);
This data can be fetch by the application layer of your dashboard, and stored in an array. You can now fetch the different stage chart data by just manipilating the array based on the index.
Trying to get the complete expected information directly from the database would be a pain in the ass.
I have a dataset that looks like the following:
| Location | Category |Item Name | Month | QTY |
| -------- | -------- | -------- | -------- | --- |
| NY | Hardware | Screw | Jan 2017 | 100 |
| NY | Hardware | Screw | Feb 2017 | 50 |
| NY | Hardware | Screw | Mar 2017 | 75 |
| NY | Hardware | Bolt | Jan 2017 | 30 |
| NY | Hardware | Bolt | Feb 2017 | 90 |
| NY | Hardware | Bolt | Mar 2017 | 50 |
| CA | Hardware | Screw | Jan 2017 | 100 |
| CA | Hardware | Screw | Feb 2017 | 50 |
| CA | Hardware | Screw | Mar 2017 | 75 |
| CA | Hardware | Bolt | Jan 2017 | 30 |
| CA | Hardware | Bolt | Feb 2017 | 90 |
| CA | Hardware | Bolt | Mar 2017 | 50 |
My report needs to look like the following:
| Hardware | Screw | Bolt |
|Current Month Total | 150 | 100 |
|Yearly Total | 450 | 340 |
I need a way to limit the current month total to ONLY the current month but aggregate the values for the yearly total. I've tried using LAST in the aggregate but you can't. I've tried the following for the current month total aggregate. My Date value is the 1st day of the month and my parameter is the last day of the month, so I needed a way to match the 2 that is why there is the date addition. The jist is to try and match the current month, which is a parameter to the date column:
=iif( DateAdd(dateinterval.Day,-1,DateAdd(dateinterval.Month,1,Fields!Sale_DATE.Value)) = Parameters!ReportingDate.Value, iif(isnothing(sum(Fields!Total.Value)),"",sum(Fields!Total.Value)),sum(0))
but it only works if the query that returns the dataset returns ONLY the current month. If the query returns all of the months in the year it shows 0's. I need a way to filter the cells so they aggregate the values correctly
If I limit my report to only the current month I can't get the yearly aggregate and if I select all of the months I can't get the current month total.
You can do this using the built-in grouping functions without any fancy expressions.
Add a row group by month. Filter the row group to the current month. Add a column group by Item Name. Add a row outside and below the row group to get your yearly totals. The expressions will all simply be a sum of the Qty. The report will take care of summing the values within each group scope.
Actually, using grouping as suggested alone doesn't work. I was already using groups in my matrix. The issue is that I needed a different form of grouping within the same column and I needed to restrict the grouping to different date ranges. My problem was that I had the SUM in the wrong position in my formula.
The expressions for the yearly total should have been:
=Sum(IIF(Fields!ItemName.Value="Screw",Fields!QTY.Value,0))
=Sum(IIF(Fields!ItemName.Value="Bolt",Fields!QTY.Value,0))
Then, based on the dataset, if the current month is "Mar 2017" I can build the expression for Month Total as
=Sum(IIF(Fields!ItemName.Value="Screw" and Fields!Month.Value="Mar 2017",Fields!QTY.Value,0))``
=Sum(IIF(Fields!ItemName.Value="Bolt" and Fields!Month.Value="Mar 2017",Fields!QTY.Value,0))
These examples are using my sample dataset in this question. Since I couldn't hard code dates, wanted to use parameters, and needed to do a calculation this is what I ACTUALLY used:
SUM(iif(DateAdd(dateinterval.Day,-1,DateAdd(dateinterval.Month,1,Fields!REL_DATE.Value))= Parameters!ReportingDate.Value,
Fields!Total_OnTime.Value,0))/SUM(iif(DateAdd(dateinterval.Day,-1,DateAdd(dateinterval.Month,1,Fields!REL_DATE.Value))= Parameters!ReportingDate.Value,
Fields!Total.Value,0))
Hope this helps someone else.
I am trying to include a cumulative total column in a matrix on a report.
This is the expression I am using at the moment:
=RunningValue(Ceiling((SUM(Fields!MINUTES.Value)/60)*4)/4,Sum,"RowGroup")
The problem is the total seems to reset on each day.
I have 3 groups on the report: Parent is Day of month, type, then sub type.
I want it so that the sub types will accumulate across the days:
So 1st june/holiday/annual = 2 - cumulative = 2
.. 2nd june/holiday/annual = 1 - cumulative = 3
rowgroup in the expression above is the 3rd level sub type group in the matrix.
Whatever I try I cannot get it to total up over the days, like i said above it seems to not carry over to the next day.
Below is a sample dataset:
+------+------------+---------+----------+---------+
| User | Date | Type | Subtype | Minutes |
+------+------------+---------+----------+---------+
| 158 | 13/02/2015 | Holiday | Annual | 90 |
| 158 | 13/02/2015 | Meeting | Training | 300 |
| 158 | 13/02/2015 | Lunch | Lunch | 60 |
| 158 | 03/06/2015 | Holiday | Annual | 120 |
| 158 | 03/06/2015 | Meeting | Meeting | 285 |
| 158 | 04/06/2015 | Holiday | Sick | 120 |
| 158 | 04/06/2015 | Holiday | Annual | 200 |
+------+------------+---------+----------+---------+
My matrix column group is the user.
The row groups are date, then type, then subtype.
I then have a total column outside the column grouping.
I'm now trying to add in to the report a cumulative total based on the type and sub-type columns, that sums up the minutes.
As an example (looking at the holiday, annual entries):
03/06/2015 - 120 minutes
13/02/2015 - 90 minutes = 210 minutes
04/06/2015 - 200 minutes = 410 minutes.
Taken from the MSDN page for RunningValue, adding a scope to your expression will have this effect.
The value for RunningValue resets to 0 for each new instance of the scope. If a group is specified, the running value is reset when the group expression changes. If a data region is specified, the running value is reset for each new instance of the data region. If a dataset is specified, the running value is not reset throughout the entire dataset.
To fix the issue, simply remove the scope:
=RunningValue(Ceiling((SUM(Fields!MINUTES.Value)/60)*4)/4,Sum)
This will have the total run across all days (As days are your top-most level). If this is incorrect could you perhaps give us an example of what the report is currently doing, and what you want it to do?
I have a database of articles, and want to make an archive nav. I want to query individual month/years in the database and also how many months were found for each year. For example:
2013 | November | 3
2013 | October | 3
2013 | September| 3
2012 | February | 2
2012 | January | 2
2011 | January | 1
2010 | February | 2
2010 | January | 2
2009 | April | 4
2009 | March | 4
2009 | February | 4
2009 | January | 4
How do I go about doing this?
You need a table to index to. I suggest the following algorithm:
Create a temporary table with all the months in one column, and years for your search in another. You can create an index on these two columns for efficiency, if this is something you'll use for other applications. You can also query your records to find the years you need to search (create a set of the available years unless you plan to add records that will be outside of the set).
For each ij pair in the table you created in step 1, count the number of records in your articles table that match the month and year condition for ij.
Good luck!
You can try to use something like this: To group by year,month + count months
For example
SELECT *,count(MONTH(date_field)) as totalCount FROM table GROUP BY YEAR(date_field),MONTH(date_field)
Objective: Convert an overgrown Excel sheet into an Access database, but maintain a front-end that is familiar and easy to use.
There are several aspects to this, but the one I'm stuck on is one of the input forms. I'm not going to clutter this question with the back-end implementation that I have already tried because I'm open to changing it. Currently, an Excel spreadsheet is used to input employee hour allocations to various tasks. It looks something like the following.
Employee | Task | 10/03/10 | 10/10/10 | 10/17/10 | 10/24/10 | ... | 12/26/11
---------------------------------------------------------------------------------
Doe, John | Code | 16 | 16 | 20 | 20 | ... | 40
---------------------------------------------------------------------------------
Smith, Jane | Code | 32 | 32 | 16 | 32 | ... | 32
---------------------------------------------------------------------------------
Doe, John | Test | 24 | 24 | 20 | 20 | ... | 0
---------------------------------------------------------------------------------
Smith, Jane | Test | 0 | 0 | 16 | 0 | ... | 0
---------------------------------------------------------------------------------
Smith, Jane | QA | 8 | 8 | 8 | 8 | ... | 8
---------------------------------------------------------------------------------
TOTAL | 80 | 80 | 80 | 80 | ... | 80
Note that there are fifteen months of data on the sheet and that employee allocations are entered for each week of those fifteen months. Currently, at the end of the fifteen months, a new sheet is created, but the database should maintain this data for historical purposes.
Does anyone have any ideas on how to create an editable form/datasheet that has the same look and feel? If not, how about an alternative solution that still provides the user a quick glance at all fifteen months and allows easy editing of the data? What would the back-end tables look like for your proposed solution?
This is a classic de-normalization problem.
To produce an editable spread-sheet like view of your database you'll need a table with 66 columns (the two identifying columns and 64 weekly integer columns). The question is whether you want the permanent storage of the data to use this table, or to use a normalized table with four columns (the two identifiers, the week-starting date, and the integer hours value).
I would give serious consideration to storing the data in the normalized form, then converting (using a temporary table) into the denormalized form, allowing the user to print/edit the data, and then converting back to normal form.
Using this technique you get the following benefits:
The ability to support rolling windows into the data (with 66 columns, you will see a specified 15 month period, and no other). With a rolling window you can show them last month and the next 14 months, or whatever.
It will be substantially easier to do things like check peoples total hours per month, or compare the hours spent in testing vs QA for an arbitrary range of dates.
Of course, you have to write the code to translate between normal and denormal form, but that should be pretty straightforward.