I have problem to show data in bar chart.
I want to show year in dimension and sum of price in expressions. Because I have a lot of data in bar chart I got no data to display.
I have idea to separate data by month like this
sum({<PostingMonth = {'JAN', 'FEB', 'MAR', 'APR', 'MAJ', 'JUN', 'JUL', 'AVG', 'SEP', 'OKT', 'NOV', 'DEC'}>} Price)
but also get no data.
If I show month by month I got result, how to sum all month to get value.
Why don't you just add PostingMonth as a second Dimension?
Related
I'm creating a filter to get expenses on a Credit Card, to generate a invoice.
But I only made it work filtering by month and year. I need get the records on days interval, and than, month and year.
For example:
Table: credit_cards
Column: close_invoice (day 25)
How do I get all expenses between day 25 of previous month and the next day 25?
This is my query filtering by month:
$thisMonth = $now->format('m');
$thisYear = $now->format('Y');
$cc_expenses = Expense::where([
['bank_id', $bank->id],
['payment_method', 1],
['parcels', NULL]
])
->whereYear('date', $thisYear)
->whereMonth('date', $thisMonth)
->get();
But this way I don't get the records between day 25 and the last day of the previous month.
Thanks in advance!
You can use
$previousMonthLastDay = now()->subMonth()->setDay(25)->setHour(0)->setMinute(0)->setSecond(0);
->whereBetween('date', [$previousMonthLastDay, now()])
I think nobody need to set future time from now, but if you need, you can do like $previousMonthLastDay without subMonth()
if your now date is 2022-04-13 12:22:10 , $previousMonthLastDay will be like 2022-04-25 00:00:00
I trying to use amchart setting
dateAxis.baseInterval = {
"timeUnit": "month",
"count": 1
}
But i have an error to show the data, when i have more than one day in the month with data, the graph show more than one bullet for the same month.
for example if I have the next data
2019-10-11 => 20
2019-10-12 => 30
in place to display
(2019-10) => 50
the graph show the next data
(2019-10) => 20,
(2019-10) => 30
Thanks in advance.
AmCharts v4 doesn't aggregate your data for you. baseInterval merely tells the chart how to render your data with the minimum intervals between your points. Setting it to month with multiple data points in the same month will display multiple points; this is as designed.
If you intend to display your data in monthly intervals and have some data points where more than one point is in the same month, you need to manually aggregate your data beforehand - in your case, convert that point to a single data item in October with a value of 50.
In my db i have a column created_at (date_time format). I would like to create an analytical dashboard when it will be possible to filter data by create_at by giving month name (one or more - multiple choice)
I have added a new calculated field "month" in data set with following formula:
formatDate(truncDate("MM",{created_at}),"MM" )
As a result i get new column with strings like "01", "02" etc.
I've created a new parameter:
name: Month
Data type: string
Values: multiple values: {01, 02, 03 ....}
I've created a new control:
name: Month
Style: Multi select drop down
Values: Link to a data set field -> Data set -> Month column
I've created a new filter for Month columns, based on Month parameter
My problem is: how to achieve the same result (filtering by month, multi select) having month names displayed in the control, not "01", "02" etc. Is it possible?
UPDATE
It is much better to have following formula in Month calculated field:
extract("MM",{create_at})
But it does not solve my problem....
What i did, but i really don't like this solution as it is so ugly.....Any better solution is welcome :)
new calculated field month_number, with formula:
extract("MM",{create_at})
new calculated field month_name with formula:
ifelse({Month_number}=1,"Jan",ifelse({Month_number}=2,"Feb",ifelse({Month_number}=3, "Mar",ifelse({Month_number}=4, "Apr",ifelse({Month_number}=5, "May",ifelse({Month_number}=6, "Jun",ifelse({Month_number}=7, "Jul",ifelse({Month_number}=8, "Aug",ifelse({Month_number}=9, "Sep",ifelse({Month_number}=10, "Oct",ifelse({Month_number}=11, "Nov",ifelse({Month_number}=12, "Dec","Error"))))))))))))
Here is a fiddle to help show what I'd like to do:
http://jsfiddle.net/m4x7o5of/
I have a set of records, each with a float value. For example:
var records = [{name: 'record1', value: 1.34563}, ..., {name: 'record5000', value: 0.62974}];
I'd like to create a barchart in dc.js that plots the records on the x-axis in range buckets, e.g x-number of records with value between 0 and .5, y-number of records between .5 and 1, z-number of records between 1 and 1.5, and so on.
I'm using an ordinal scale so that I can divide the set of records into 5ths, but I can't figure out how to get the records grouped together in the ranges like I described. In the linked fiddle, only the records with a value that matches the plotted ordinals will get displayed right now.
Is it even possible to group the records like this? Any help would be appreciated.
dimension.group takes a function that you can use to derive the group key. So dimension.group(function(d) { return Math.floor(d); }); will give you group keys of 0, 1, 2, 3, 4, 5, 6, 7, and 8 for your data set. You'll just need to construct a function that returns the values you want based on the values in your data set. Is that what you're looking to do?
I'm a new to slickgrid, and not sure how to display the data as attached with the screenshot below. I read grouping example, but it's grouped by an existing column and not sortable. In the example, each category has multiple items with prices, and it's sorted by Category name and price.
Any help with displaying the data so that category is sortable is greatly appreciated.
Thanks so much.
Lanny
After spending more time with the examples, I learned that I can define what I want to display in columns obj. In data obj, I can have as many properties as I want.
In the code example, the first column is the actual product, but the name is Category, it's kind of confusing but it's a business decision. After I added all the data, I added the category name in product column and set colspan to "*" before each group of products, so it expands to all columns. I'm sure that SlickGrid DataView group has a better solution than this, right now I haven't gotten that far. If someone can elaborate more on how to use DataView, I appreciate it.
code example: http://jsbin.com/efujox/2/
columns = [
{id:"product", name:"Category", field:"product"},
{id:"price", name:"Price", field:"price"},
{id:"date", name:"Date", field:"date"}
];
data =[
{id: 'p1', product: 'Item 332', category:'Category XBC', price: 5.99, date: '6/19/11'},
{id: 'p2', product: 'Item 12', category:'Category XBC', price: 6.99, date: '8/20/11'},
{id: 'p3', product: 'Item nVV', category:'Category CXV', price: 4.99, date: '5/11/12'},
{id: 'p4', product: 'Item dcA', category:'Category CXV', price: 9.42, date: '8/11/11'}
];