How to nest kusto query based on grouped value - nested

I have a table that contains items and their changing prices depending on the dates.
gold 12-jan $400
gold 15-jan $440
silv 13-jan $100
silv 10-jan $090
I need a kusto query that can fetch me the item and its latest price.
so output be:
gold 15-jan $440
silv 13-jan $100

Use arg_max
For example:
T | summarize arg_max(timestamp, *) by item

Related

Joining multiple Table using sequelize

I have 4 table t1,t2,t3,t4 in a POSTGRESQL database. Each of the table contains 3 common field, "currency" eg INR DOLLAR etc, "debt" eg 12006 , "credit" eg 1000. Credit and debt are integers.
Each table contains multiple entries of every currency possible
I want the sum of debt and credit of each currency across all the 4 tables
currency
debt
credit
INR
12006
1000
DOLLAR
50002
3012
yen
1234
12546
I'm using sequelize, there's no realtion between any 4 tables, I'm only able to add credit and debt of 1 table at a time using this
var a = await asset.findAll({
attributes: ['currency',[sequelize.fn('SUM', sequelize.col('credit')),
'credit'],
[sequelize.fn('SUM', sequelize.col('debt')), 'debt']
],
group: ['currency'],
});
can someone please guide me how can I make a complete outer join using sequelize preferably else raw query would also work

Combine columns of Pivot Table in Excel

I have a pivot table that displays the Count of Items, the Avg. Sell Price, and Avg. Supplier Price. I need to find the difference between the Sell Price and Supplier Price and their percentage difference. I have tried using Calculated Fields, but they only work on an individual cell level. The data is organized as Purchaser, Item, Item Id, Sell Price, Supplier Price.
My table is as follows:
Row Labels (Item) | Count of Item Id | Avg of Sell Price | Avg of Supplier Price
A | 3 | $2 | $1.9
B | 4 | $3 | $3.25
I know the difference would be Avg. of Sell Price - Avg of Supplier Price, but you cannot subtract columns in a Pivot Table.
How does one perform this calculation?

Count of number of unique customers by month

I have a spreadsheet that contains data for customers that have purchased items from my store. What I would like to do is go back the last couple years, using a pivot table, and display: number of customers that ordered something each month (a count of unique customer names).
The sheet is organized as such:
Date | Invoice | Account Name | Item | Quantity | Amount
6/1/2020 | 50100 | John's Tire Shop | 1/2 Inch Socket | 2 | 12.00
Is there a way inside pivot table options to count unique account names and display the total grouped by month?
You can create a helper column to identify unique values per month to add as a filter to your pivot using your existing setup
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1,"y","n")
I would propose you to add a helper column to your data, containing the =Month(A:A) function. But be careful: I see that your first date equals "6/1/2020", is that the first of June or is this Epiphany? :-)

How do I negate a value in an Excel calculated field for a pivot table?

I've got a pivot table that has a sum of numbers aggregated per month per category. My data table looks like this:
Date | Description | Amount | Transaction Type | Category | Account Name
---------------------------------------------------------------------------------
12/16/2017 | Dinner | 150.00 | debit | Restaurants | CC
12/16/2017 | Return | 80.00 | credit | Restaurants | Cash
For the calculated field's formula, I've tried =IF('Transaction Type'="credit", -1*Amount, Amount) but it's just giving me the same sum of Amount. For this sum, I'd expect it to be 70.00 (150 - 80). Not sure what to do here.
You are after adding a calculated item rather than a calculated field as you are relying on the value of the field "Transaction Type" to determine the calculation result. See reference here
I assumed (oops) you meant credit - debit but, if not, simply swop the items around in the formula.
With your initial pivottable set up
With either Debit or Credit in the column headers of the pivot selected goto
Fields, Items, & Sets in the Analyze tab and selected Calculated Item
then add the following:
Name: Net
Formula: =' credit '-' debit '
Example layout final:
As noted in the link:
You will:
NOT be able to move the field to the Report Filters area
NOT be able to add multiple copies of a field to the Values area.
Extra items might be created in the pivot tables, such as cities
appearing in all regions, with zero values.

Pragmatically Get Count of Pivot Table Data

Suppose I have some sample data like so:
and I create a Pivot Table and order by Product > Sales Rep > Sales
If I want the # of sales John had for Product1 I would do =GETPIVOTDATA("Sales",$A$3,"Product","Product1","Sales Rep","John")
But how would I get a count of the entries there are. i.e. for Product1, John had 4 and Kevin had 2
Is it possible to get this count using GETPIVOTDATA()?
To get this you need to add another Sales field to the values section and change the "Summarize By" to Count. Then the formula will =GETPIVOTDATA("Count of Sales",$A$3,"Product","Product1") will get you the count of Product Overall.

Resources