Accessing property in the previous tumbling window - azure-stream-analytics

I need to count if a specific property has changed between two tumbling windows, I need its value from both the windows. Is it possible to access the value of a property in the previous window?
For example, I need to count the unassigned orders. Assigned orders can be put back to unassigned status. The orders can be changed for several other reasons. I need to show in a 1-hour window how many orders when into unassigned status. Just counting by, where unassigned = true will not give the desired result. It has to be something like where unassigned = true and (currentWindow.unassigned != previousWindow.unassigned)
Is this possible to do in Azure Stream analytics?

Related

Shopware API search products endpoint total from a stream inconsistent

I have two dynamic product groups
First: Test Product with variants
Conditions: Product Is equal to Variant product
Result total 7 like I expect this
Second: Active Products
Conditions: Active yes
we allready see that the stream ids are just set to 5 products
Now we get a total of 5 instead of 15 products like expected?
Why is it inconsistent, and how can I modify my request to consider also the variants?
You shouldn't rely on the stream_ids column as an indicator which product is shown in a dynamic product group at any given moment. This is because there are multiple more things that factor into whether a product is shown to a user in a dynamic product group.
The filters you define for the group resolve to an SQL query, which in simplified terms would yield something like WHERE active = 1 AND id IN ('...', '...'). So the stream_ids column isn't used to select the contents of a group, but the entire query including all filters is executed in the storefront request. The result of that query is what you see in the preview of the dynamic product group.
Why doesn't it correlate completely with the content of stream_ids?
Shopware features inheritance of fields. If fields of a variant haven't been assigned a value, they may inherit that value from their parents. This may not be reflected in the contents of stream_ids. In fact the children/variants may even inherit the contents of stream_ids.
Then there's the fact that contents of the product group may vary, depending on the current sales channel. That may be because the sales channel features a different language, hence the content of a translatable field used in a filter may vary. Also if you use price filters, there is the possibility of products with multiple prices, which might only be shown if certain conditions are met, defined by the rule builder.
In short, don't count on the stream_ids, which can't reflect all these variables but are used in some capacity internally, for invalidating caches and such. Instead use the preview to judge what the average user might find when they see a product group. There's also the possibility to choose which sales channel the preview should apply to, for the exact reason, that contents may differ depending on the sales channel.

CloudKit, NSPredicate to return a count or determine if any records exists , in a private container?

I've been researching how to determine is any RecordType records exists in a Private Container, perhaps from a previous app installation or from another device in the users iCloud account.
I see that you can not perform an NSPredicate count of records.
However I can't find an alternative to find if any records exists?
There is no way to get a count.
If you wish to determine if there are any records for a given record type, perform a CKQueryOperation for the given record type. Set the query's predicate to [NSPredicate predicateWithValue:YES] and set the operation's resultLimit to 1.
Then check the results. You'll either get one row back if there are any records or you'll get no rows back (or possible an error, see what happens).

CDC LSNs: queries return different minimum value

I have CDC enable on a table and I'm trying to get the minimum LSN for that table to use in an ETL job. However when I run this query
select sys.fn_cdc_get_min_lsn('dbo_Table')
I get a different result to this query
select min(__$start_lsn) from cdc.dbo_Table_CT
Shouldn't these queries return the same values? and if they don't why not? and how to get them back in sync?
The first query:
select sys.fn_cdc_get_min_lsn('dbo_Table')
Invokes a system function that returns the lowest POSSIBLE lsn for the capture instance. This value is set when the cleanup function runs. It is recorded in, and queried from, cdc.change_tables.
The second query:
select min(__$start_lsn) from cdc.dbo_Table_CT
Looks at the actual capture instance and returns the lowest ACTUAL lsn for the instance. This value is set when the first actual change to the instance is logged after the cleanup function runs. It is recorded in, and queried from, cdc.dbo_Table_CT.
They're unlikely to tie out, statistically speaking. For the purposes of an ETL job, using the call to the system table will likely be quicker, and is a more accurate reflection of when the current set of change records started being accumulated.

How to group records where a subset matches a condition

I have created a Microsoft report in VS2008 that displays details of products that are tested in a factory. Relevant fields to this problem are: SerialNumber (int), Pass (bool).
There is also a record ID which means several entries may exist per SerialNumber.
What we would like the report to show is to be grouped where SerialNumbers have never met the condition Pass=True (i.e. actual rejects) and the rest under where at least one record shows Pass=True.
The expression for the grouping currently is "=Fields!Pass.Value" which splits pass and fail records (and are then sorted etc).
In case anyone else comes up against this and wants to know how I solved it, I added an extra boolean column to the SQL query called 'Reject' which returns true or false and used this to group the report.
As powerful as the reporting can be, it just appears to be quite limited on what it can do with set data beyond Count, CountDistinct etc.

Calculated member not showing totals

i have the following script in my cube:
/*
The CALCULATE command controls the aggregation of leaf cells in the cube.
If the CALCULATE command is deleted or modified, the data within the cube is affected.
You should edit this command only if you manually specify how the cube is aggregated.
*/
CALCULATE;
CREATE MEMBER CURRENTCUBE.[Measures].[Scope TEST]
AS
STRTOVALUE(2),
VISIBLE = 1;
SCOPE([Locations].[LocationName].Members, [Measures].[Scope TEST]);
this = SUM([Locations].CURRENTMEMBER, STRTOVALUE(1));
END SCOPE;
what i would like for the script to do, is the following;
i have 5 locations, so when i add the measure scope test it should display 1 after each row. which is fine.
it, however, does not display 5 in the grand total row.
this is a simplified version of a script im trying to use. in that script i have yet to use a scope, but with a scope statement or without it, it doesn't really matter since there are no differences.
if anyone could point me in the right direction, any help would be much appreciated.
Are you seeing 1 in the grand total? If so, it may be that SUM(ALL, 1) = 1, as the ALL member does in a way count as a single member.
Try adding the All member's descendants into the count like this and let us know how it goes:
SCOPE([Locations].[LocationName].Members, [Measures].[Scope TEST]);
this = SUM(DESCENDANTS([Locations].CURRENTMEMBER, , AFTER), STRTOVALUE(1));
END SCOPE;
The Descendants function will return the set of descendants, so the All member will have all it's children (The members) evaluated for the set. So you'll get five members, summing that at one each should give you the number 5.