Azure Application insights for web, display unique users in power BI - asp.net-mvc

We set up web analytics using Application Insights -> Stream Analytics -> Power BI path.
We would like to see the chart of daily unique visitors in Power BI dashboard.
Users are considered unique if [context].[user].anonId are different. Time is placed in [context].[data].eventTime in insights json.
The export query should look something like that (we know how to address missing unique keyword, so I'll use it for simplicity):
SELECT
count(unique A.[context].[user].anonId)
SYSTEM.TIMESTAMP
FROM
[export-input] A
TIMESTAMP BY A.[context].[data].eventTime
GROUP BY
TumblingWindow(day, 1)
The problem is TIMESTAMP BY does not support qualified fields. Without that, we're actually timestamping users not by actual page visit time, but by the time this data entered stream analytics. This means, we might loose a bunch of unique uesrs, or count some of them twice.
Is there a workaround for that?

TIMESTAMP BY now supports qualified fields, so it should not be a problem anymore. However, please note that Stream Analytics does not have Unique/Distinct keyword. You will need to rewrite your query like this to compute unique count:
WITH step1 AS
(
SELECT
COUNT(*) countPerAnonId
FROM
[export-input] A
TIMESTAMP BY A.[context].[data].eventTime
GROUP BY
A.[context].[user].anonId,
TumblingWindow(day, 1)
)
SELECT COUNT(*)
FROM step1
GROUP BY System.Timestamp

Could you, on the ASA side, just submit the 'view time' as a property of your event (from the client) and then select across that in ASA. I'm not that familiar with ASA's limits, but I can find someone to help if the above doesn't work. In Power BI you can make Q&A queries like "show distinct anonID in the last 24 hours" or "... in the last day". Which if there's a date field, should match your expected behavior.

Related

How to auto-fill reports like this (google sheets)

i need to filter a report generated by a time tracking software. However the format delivered is not the best to filter.
What i want as result is a list of employees (firstname, last name, department, sum(presence.Corona))
My plan was to use google docs and our HR department should paste this report each month in a new sheet. Then the first sheet generates the overview for each month-sheet. i could do this IF the firstname and last name would be in every line. Unfortunately it isnt. So i need to somehow automate that this is pasted in every line or i need to select all data and then group from (including) firstname 1 until (excluding) firstname 2 and so on.
At the moment i have no clue on how to do this. any ideas on maybe doing this with google sheets query feature?
Thank you for your ideas :)
I tried using google sheets query feature but i think i first need to fill the data

Updating a query for false positives

I work in a compliance role at a very small start-up and review a lot of information,for example bank transfers/direct deposits/ACHs every day. A report is pulled from BigQuery,which is exported to Google Sheets.
My question is there are a lot of false positives (basically, "posting data" that repeats often). I'm trying to eliminate it.
One idea, was just to update the query for key words:
WHERE postingdata LIKE 'PersonName%'
But it's tired and time-consuming. And I feel e there's a better way, perhaps 'filtering' the results and then feeding it back to the query. Any ideas or tips or just general thoughts?
In this case you can use group by in your query. This is how you can use this clause.
You can see this code.
SELECT account,TypeTransaction,amount,currency
FROM `tblBankTransaction`
The code returns this data, and some rows are repeated; for example, rows 1 and 7 with the account 894526972455, and it's a deposit.
In this case, I will use the group by clause.
SELECT account,TypeTransaction,amount,currency
FROM `tblBankTransaction`
group by account,TypeTransaction,amount,currency
And it returns this data:
You can see in this example that the account 894526972455 with a deposit only returns 1 row. The same account returns a second row, but is a transfer; it’s a different type of transaction. It depends on the information you have and what column you want to group.
within GS you can try UNIQUE or QUERY with group by aggregation or SORTN with mode 2 as 3rd parameter

Rails: select records with maximum date

In my app users can save sales reports for given dates. What I want to do now is to query the database and select only the latest sales reports (all those reports that have the maximum date in my table).
I know how to sort all reports by date and to select the one with the highest date - however I don't know how to retrieve multiple reports with the highest date.
How can I achieve that? I'm using Postgres.
Something like this?
SalesReport.where(date: SalesReport.maximum('date'))
EDIT: Just to bring visibility to #muistooshort's comment below, you can reduce the two queries to a single query (with a subselect), using the following form:
SalesReport.where(date: SalesReport.select('MAX(date)'))
If there is a lot of latency between your web host and your database host, this could halve execution times. It is almost always the preferred form.
You can get the maximum date to search for matching reports:
max_date = Report.maximum('date')
reports = Report.where(date: max_date)

Quickbooks Online REST API: Is it possible to apply Date functions in the SQL query?

I want to retrieve invoices in which date difference between today and DueDate is > 1 or more. Is there anyway to apply some kind of DateDiff?
I'm using the QuickBooks Online API indicated here:
https://developer.intuit.com/docs/api/accounting/invoice
And issuing an SQL query via their REST API like this:
Operation: GET /v3/company/<realmID>/query?query=<selectStatement>
Content type: application/text
Where my <selectStatement> is something like:
SELECT * FROM Invoice
I need the equivalent to something like this that I'd do in MySQL:
SELECT * FROM Invoice WHERE DATEDIFF(NOW(), DueDate) > 1
Can I do that with Intuit's SQL-like query REST API?
If you refer to Intuit's docs, it shows what is filterable.
https://developer.intuit.com/docs/api/accounting/invoice
Relevant:
DueDate:
optional
Date, filterable, sortable
There is no "date difference" type function available. Intuit's limited SQL-like query language does not support it.
You may also wish to check out the A/R Aging reports, which are specifically geared towards things like finding overdue invoices (which is what it sounds like you're trying to do).
Example:
https://developer.intuit.com/docs/api/accounting/ar%20aging%20summary

How to offer parameter for user to select an amt and then show that data

I have done report that shows summary of sales of items by free shipping or not free shipping. They are actually Product lines, that get free shipping or not.
It looks like this.
date Invoice# Free PL NOt free PL etc.
061113 1234 $29
061213 5678 $89
They want to have the flexibility to select ranges of BOTH free PL’s and non-free PL’s (e.g., “free PL’s over $70 and non-free over $30”, or “free PL’’s over $80 and non-free PL’s over $25” etc.)
They want to specify I guess in the param what amount then the CR should display according, so that in out case here only the second line would show.
Is this able to be done just in the param? if so, how would you code this?
this method may be a bit lengthy but will work for you hopefully.
make a table named PL history, now give it three fields, with ID, PL_DATE and PL_RATE, you need to insert new record in to that daily. if you want it to be more finer, add another column as PL_TIME as well. now when inserting the PL_Transaction, make sure that you enter time to that table as well.
Once it is done, make a view and like the transaction table with the respective PL_DATE and PL_TIME if you incorporate time, this will ensure that you pick the right PL specified during the transaction. YOu can do it behind the generate report button, will take no time to execute.
JUst call that view to the report, and get your specific PL using the formulas,
I tried calling a field to the report mannualy, it did come to the report, but it could not be called to the formula editor so , I thought of this solution , may help. thanks

Resources