pagination for facebook-graph-api - facebook-graph-api

I am using the graph-api to fetch data for a specific query.
I am using the value of "next" field for pagination.
Suppose
The link is http://graph.facebook.com/search?q=blade&type=post&limit=300&until=1322857230
This page has 2 links
"previous" and "next"
Now when i hit the previous link, i am getting results having latest time stamp.
How is this possible? Previous link should have data with older time stamps.

That previous link has the updated data bcoz you are seeking the "blade" keyword until 2nd December so first page is getting the data from 2nd December and the previous one is getting the updated data , so on . But if you use http://graph.facebook.com/search?q=blade&type=post&limit=300&until=1323167000 then its searching until 6th December so there is no updated date for 6th December , thats why its previous page is blank .
Example :
Suppose there are 2000 post for "Blade" keyword from 2nd dec , So your query is returning the first 300 results starting from 2nd dec , lets say there are 500 results from 2nd December so in first page you are getting 300 and in previous page you will get rest of the 200 and another 100 result from 3rd December .
Make senses ?

Related

Case statement for the time section in a timestamp SQL

All, I am trying to isolate the time portion only of a date/time stamp and then create a case statement to populate another column with data. This is how the date/time stamp looks: 2022-03-25 04:00:00
Here is the code I originally wrote but when I just use the hours portion I get an error in PowerBi saying invalid date/timestamp...
case when create_tmstp between '04:00:00' and '07:30:00' then 'N' else 'D' end as Day_Night,
From the looks of it, you're using SQL, not DAX. I say that, because you've tagged this with dax and not SQL.
Problem is that you're not showing us what create_tmsp is, or what version of what kind of sql server you're using. So, just to make it easier, this is an working example to use for instance inside SSMS. This uses getdate() to get the current datetime, and then converts it into just showing what hour it is (0-24), then there is a case when that checks which intervall it falls under. You can use this, and simply replace getdate() with the column you wish to use if you're using a server that accepts this syntax.
select
DATEPART(HOUR,getdate()) AS 'HOUR',
getdate() AS 'Datetime',
CASE WHEN DATEPART(HOUR,getdate()) BETWEEN 9 AND 16
THEN 'Day'
WHEN DATEPART(HOUR,getdate()) BETWEEN 17 AND 24
THEN 'Evening'
WHEN DATEPART(HOUR,getdate()) BETWEEN 0 AND 4
THEN 'Night'
WHEN DATEPART(HOUR,getdate()) BETWEEN 5 AND 8
THEN 'Morning'
END AS 'Label'
Example result:
Hour
Datetime
Label
0
2022-04-04T00:18:13.203Z
Night
Fiddle here:
http://sqlfiddle.com/#!18/56f78/3829

I'm trying to get Last month to date in Power BI

I have a Power Bi dashboard tracking several metrics since the beginning of last month . Some of the comparisons I make are MTD vs Last MTD count of metrics like Total users, No of posts and connections made.
MTD(June) and LMTD(May) were working well last month(June) but when we moved to a new month(july) the numbers are off.
Here's my measure
MTD_Users = CALCULATE(COUNTROWS('reporting profiles'), FILTER('reporting profile', MONTH('reporting profile'[date_created])=MONTH(TODAY())))
LMTD_USERS = CALCULATE(COUNTROWS('reporting profiles'), FILTER('reporting profile', MONTH('reporting profile'[date_created])=MONTH(TODAY())-1))
Since July 2nd these measures are not displaying correct figures for MTD(July 1st) and LMTD(June 1st)
Any advice/assistance will be highly appreciated
You need to ride off contex filter and that mean we must use function ALL or REMOVEFILTERS;
https://dax.guide/removefilters/
https://dax.guide/all/
LMTD_USERS = CALCULATE(COUNTROWS('reporting profiles'), FILTER(ALL('reporting profile'[date_created])), MONTH('reporting profile'[date_created])=MONTH(TODAY())-1))

How to get the reference of a cell based on two filters in Google Sheets?

I am parsing JSON data from a FB Ads Campaign through Graph API in Google Sheets. I have multiple sheets for different ad insights based on a timeframe (today, yesterday, 7 days, 30 days) and a dashboard that shows a snapshot of the most important data like the # of conversions and cost-per-conversion for each campaign.
On the dashboard page, I want to match the Adset ID with the value next to cells that contain 'complete_registration' on an insight page.
This is the current formula I have
=INDIRECT(INDEX("h"&filter(ROW('Todays Insights'!G1:G901),'Todays Insights'!G1:G901="complete_registration")),1)
This works for referencing the first time 'complete registration' is used... but I want the value for each Adset
For example -> IF Column A has Adset_ID and Column B has Complete registration then index value in C
What formula would accomplish this in Google Sheets?
Picture Example
O.K. I think I get it. You want to get 2 coulmns as a result - B and column H when C is registration_complete.
Try:
=filter({'Todays Insights'!a1:a,'Todays Insights'!h1:h},'Todays Insights'!c1:c="complete_registration")
Here is the formula I used that works:
=DGET('Sheet Name'!$A$1:$N$500,"Actions Value",{"Adset ID","Actions Action Type";C24,"lead"})

AM/PM timeline in amCharts

I'm having an issue changing the timeline to show 12 hour time with AM/PM instead of 24 hour time.
Adding this line to the timeline chart correctly changes the tooltip to display in AM/PM format:
dateAxis.tooltipDateFormat = "hh:mm a";
According to the documentation adding this line should do the same for the timeline along the X-axis:
dateAxis.dateFormatter.dateFormat = "hh:mm a";
Here's the example I'm using to test.
It isn't working however and there don't seem to be any examples of this working that I can find.
Is this feature not yet working in v4?
Thanks
You have to set the date format directly on the dateAxis' dateFormats object as documented here, e.g.:
dateAxis.dateFormats.setKey('hour', 'hh:mm a');
Codepen

Short record query with Django ORM

Can I modify the following query to make it more concise way using Django ORM?
queryset.filter((Q(from_date__lte=from_date) & \
Q(to_date__gt=from_date)) | \
(Q(from_date__lte=to_date) &
Q(to_date__gt=to_date)))
Here are some examples:
"from_date": "2014-05-11 08:00:00",
"to_date": "2014-05-11 10:00:00",
"from_date": "2014-05-12 12:00:00",
"to_date": "2014-05-12 15:00:00",
These are the dates in the database
If you submit
fromDate=2014-05-11 08:00:00
toDate=2014-05-11 13:00:00
should give me only the first date
"from_date": "2014-05-11 08:00:00",
"to_date": "2014-05-11 10:00:00",
Here again, should give me only the first result
fromDate=2014-05-11 09:00:00
toDate=2014-05-11 13:00:00
If I submit the following date
fromDate=2014-05-11 07:00:00
toDate=2014-05-11 09:00:00
Again, only the first result should be taken
If you do so you can get both results
fromDate=2014-05-11 09:00:00
toDate=2014-05-12 13:00:00
I hope you understand what's the idea.
The query should remain the same logic!
queryset.filter(to_date__gt=from_date, from_date__lt=to_date)
That is, to be returned the event must end after the new event starts and must start before the new event ends. Anything that ends before the new from_date is not returned, neither is anything that doesn't start until after it ends.
That does not precisely match your original query, but it does match the behavior described in the comments for when there's a record in the database that is entirely within the range set by the new dates.