I am totally new at spotfire environtment. I want to create new calculated column as growth of the other column. Here is my data :
Item || Date || Value || Growth
A || 12/12/2014 || 102 ||
A || 13/12/2014 || 121 || 19
B || 12/12/2014 || 141 ||
B || 13/12/2014 || 111 || -30
How to create Growth column with custom expression?
I already get some sample code that solve the similar problem. But, i still got an error.
first of all i create hierarchy named Hirarki that include Item and Date.
then i create this custom expression, but there's an error said that "couldnt find hierachy : 'Hirarki'"
sum([value]) OVER (intersect(parent([Axis.Hirarki]),[Axis.Hirarki])) - sum([value]) OVER (intersect(parent([Axis.Hirarki]),previous([Axis.Hirarki])))
Why spotfire couldnt find my hierarchy?
Thank you,
Cheers
I think this formula calculates what you need
Sum([Value]) OVER ([Item],[Date]) - Sum([Value]) OVER (Intersect([Item],Previous([Date])))
Related
Hi Kusto Query Language(KQL) lovers,
I am trying to write a query in Kusto Query Language (KQL), that can compare count of APIs that failed today in a specific time (lets say 2:30 p.m. to 3 p.m.) with respect to count of APIs that failed yesterday in the same timeframe (2:30 p.m. to 3 p.m.).
For instance, if today, in last 30 min operation X was failed 10 times with failure code 400, I need to see count with which operation X failed today in last 30 minutes (Same time frame).
For this purpose, I used Scalar function bin() and wrote following query that extracts data from request table:
requests
|where timestamp > ago(1d)
| where client_Type != "Browser"
| where (cloud_RoleName == 'X')
| where name != 'HTTP GET'
| where success == false
| summarize count() by bin (timestamp, 1d), name, resultCode
|sort by timestamp
Here is the output I got when using timestamp > ago(1d). This way, I was shown APIs that failed today and yesterday but there is no clear comparison between both dates.
Is there any way I can display count of APIs that failed yesterday on separate Column adjacent to the count_ Column that has count of corresponding APIs that failed today?
I know of project operator that adds extra column but I don't know how to incorporate and assign count of APIs that failed yesterday to project operator.
Kindly add to my knowledge of any relevant function or operator in KQL that can achieve this task.
The other way I tried was to define two variables, startDateTime and endDateTime to get the data of specific time as shown below.
Blank Output when I defined variables to define selected time frame:
let startDateTime = todatetime("2023-02-07 06:35:00.0");
let endDateTime = todatetime("2023-02-07 06:35:00.0");
requests
|where timestamp > startDateTime and timestamp < endDateTime
| where client_Type != "Browser"
| where (cloud_RoleName == 'web-memberappservice-weu-prod')
| where name != 'HTTP GET'
| where success == false
| summarize count() by bin (timestamp, 1d), name, resultCode
|sort by timestamp
I searched about KQL query to compare count of failed APIs for today with respect to count of APIs that failed yesterday and checked some results from Stack overflow which are not helping me in achieving desired result.
I tried these links but queries on these links do not reflect what I want to achieve:
Best way to show today Vs yesterday Vs week in KQL azure monitror
kql query to compare the hour which has minimum number of TriggersStarted from last week to today past hour TriggersStarted
What am I expecting?
I want a query that can display count of APIs that failed yesterday on separate Column adjacent to the count_ Column that has count of corresponding APIs that failed today.
I know of project operator that adds extra column but I don't know how to incorporate and assign count of APIs that failed yesterday to project operator.
Kindly identify any relevant function or operation that can help in this regard.
* The where clause was added for performance reasons.
// Sample data generation. Not part of the solution.
let requests = materialize(range i from 1 to 100000 step 1 | extend timestamp = ago(2d * rand()), name = tostring(dynamic(["PUT", "POST", "PATCH", "GET"])[toint(rand(4))]), resultCode = 400 + toint(rand(3)));
// Solution starts here.
let _period = 30m;
requests
| where timestamp between (ago(_period) .. _period)
or timestamp between (ago(_period + 1d) .. _period)
| summarize todayCount = countif(timestamp between (ago(_period) .. _period))
,YesterdayCount = countif(timestamp between (ago(_period + 1d) .. _period))
by name, resultCode
|sort by name asc, resultCode asc
name
resultCode
todayCount
YesterdayCount
GET
400
91
100
GET
401
98
98
GET
402
109
89
PATCH
400
93
77
PATCH
401
84
85
PATCH
402
74
82
POST
400
78
85
POST
401
96
77
POST
402
85
102
PUT
400
98
81
PUT
401
97
85
PUT
402
77
83
Fiddle
So I have the following pivot table report through my data model. I want my measure 'Branches
Per Cluster' to consider the current column of month or year.
I have the following tables aside from a generated calendar table, these two below are related by 'CODE'.
A dim table named 'Branch Profiles'
CODE
AREA
CLUSTER
DATE OPENED
AAA
Area 1
Cluster 1
01/05/1990
AAB
Area 1
Cluster 1
05/03/2022
ABA
Area 2
Cluster 1
01/03/2005
BAA
Area 3
Cluster 2
01/03/2024
A fact table named 'BasicData'
CODE
Volume
Value
Date
AAA
1000
10000
06/01/1990
AAB
2000
20000
06/01/2020
ABA
3000
30000
06/01/2005
BAA
4000
40000
06/01/2008
This is what I currently have for my Branches Per Cluster measure which might be obvious for experienced users that is syntactically wrong though I believe it shows what I was trying to do as
I'm not quite sure how to reference the column as a filter. Basically, I just want to count the Branches ("CODE") for the specific area that have a date opened before the month specified by the column filters.
=CALCULATE(
DISTINCTCOUNT('Branch Profiles'[CODE]),
ALLEXCEPT('Branch Profiles',
'Branch Profiles'[AREA],
'Branch Profiles'[CODE]
),
YEAR('Branch Profiles'[DATE STARTED]) <= 'Calendar'[Year],
MONTH('Branch Profiles'[DATE STARTED]) <= 'Calendar'[Month Number]
)
Here is the proper code for the Measure that I was trying to accomplished. What I was missing earlier was a way to reference the current value of the Year and Month columns (Context Filters) and use it as a criteria on the [Date Started] column to get the count on [CODES] that are opened on or before currently specified Month or Year.
If this was done in PowerBI the solution would have involved the function named "SELECTEDVALUE" however, the logic can still be implemented in Excel through the longer syntax shown below in my measure.
VAR cur_year =
IF (
HASONEVALUE('Calendar'[Year]),
VALUES('Calendar'[YEAR])
)
VAR cur_month =
IF (
HASONEVALUE('Calendar'[Month]),
VALUES('Calendar'[Month Number])
)
RETURN
IF(
NOT ISBLANK([Send Volume]),
CALCULATE(
DISTINCTCOUNT(Branch Profiles[CODE]),
ALLEXCEPT('Branch Profiles',
'Branch Profiles'[AREA],
'Branch Profiles'[CODE]
),
'Branch Profiles'[DATE STARTED] < DATE(cur_year, cur_month + 1, 1)
)
)
I'm trying to calculate weight average per user for three different processes. My table looks like this:
User || Process || Bonus[%] || Weight
John Smith || RETURNS || 5 || 2
John Smith || PUTAWAY || 10 || 3
John Smith || RECEIVING || 7 || 1
So basically I want my formula in each row to look like this:
=SUM.PRODUCT({5,10,7},{2,3,1})/SUM({2,3,1})
The formula needs to have an array of values based on the User Name. How can I do that?
Try formula:
=SUMPRODUCT((A2=$A$2:$A$7)*($C$2:$C$7)*($D$2:$D$7))/SUMPRODUCT((A2=$A$2:$A$7)*($D$2:$D$7))
You can use this:
=SUMPRODUCT(--(user_name_column="user name"),[Bonus %],[Weight])/SUMIF(user_name_column,"user name",[Weight])
adjusting the ranges to match your data locations.
So, I have a list of products where I report which manufacturing facility currently makes it, as well as the QTY I need to make. Separately, I have a list that tells me ALL facilities that are equipped to manufacture that product.
What I'm looking to do is make a report that can show me, at a glance, how much work is available to offload from one facility to another.
Current Manufacturer Builds
Product || MFGR || QTY to Build
A || 1 || 100
B || 2 || 50
C || 3 || 100
All Product/Manufacturer Combos
Product || MFGR
A || 1
A || 2
B || 2
B || 3
C || 3
So, from the above lists we can infer:
Product A can be made at either facility 1 or 2, but it's currently set to build at facility 1
Product B can be made at either facility 2 or 3, but it's currently set to build at facility 2
product C can only be made at facility 3
From all this, I would like to have a report that shows the following information:
From MFGR || To MFGR || Avail QTY
1 || 2 || 100
1 || 3 || 0
2 || 1 || 0
2 || 3 || 50
3 || 1 || 0
3 || 2 || 0
Where, in this report, it recognizes that:
Product A's build QTY CAN be offloaded from facility 1 to 2, so it reports a possible move of 100 from 1 to 2
Product B's build QTY CAN be offloaded from facility 2 to 3, so it reports a possible move of 50 from 2 to 3
Note that the report ignores the product (it will need to since my actual file has 100's of products, and like 10 facilities), though I recognize it needs to take it into consideration in the formula.
Is there a single-cell formula that can get this done? I was using SUMIFS() to grab the Build QTY of the "From MFGR", but I wasn't sure how to incorporate that with anything else.
You can use this array formula:
=SUM(SUMIFS(C:C,A:A,INDEX(E:E,N(IF({1},MODE.MULT(IF($F$2:$F$6=I2,ROW($F$2:$F$6)*{1,1}))))),B:B,H2))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
I've answered this question with detailed example, twice within the last week!
Detailed Instructions & More...
Stack Overflow: User defined concatenate
Stack Overflow: How can I turn part of the Excel data to columns to get a desired output?
Unpivot Excel Data
Stack Overflow: How do I ask a good question?
Stack Overflow: How do I Search?
A challenge for the excel users:
I have a table with the following columns:
Year || Week || Output
2011 || 50 || 1000
2011 || 51 || 2000
2011 || 52 || 1500
2012 || 01 || 1200
2012 || 02 || 1700
2012 || 03 || 1900
I want to sum the values on the column output that are between a given year/week and another year/week. Example:
between 2011/50 and 2011/52. Result = 1000+2000+1500 = 4500
between 2011/51 and 2012/02. Result = 2000+1500+1200+1700 = 6400
Thank you all in advance.
Regards,
MH
My steps:
Year = A, Week = B, Output = E
Create a temp column (C) holding: {Year}*100 + {Week}
Create two input sets for the boundaries (also with {Year}*100 + {Week}) -- <LOW> & <HIGH>.
Create a temp column (D) with this formula:
=IF(AND(C2>=<LOW>,C2<=<HIGH>),1,0)*E2
Then the summation cell becomes:
=SUM(D:D)
EDIT: Found another way with no D column from above
N1 = LOW (year*100 + week)
O1 = HIGH (year*100 + week)
N2 => =TEXT(N1)
O2 => =TEXT(O1)
=SUMIFS(E:E,C:C, CONCATENATE(">=", $N$2),C:C, CONCATENATE("<=", $O$2))
You can use SUMIFS(), in case that you're using Excel 2007 or above.
Example
=SUMIFS(C2:C7, A2:A7, "=2011", B2:B7, ">49", B2:B7, "<53")
Otherwise you can still use Excel Macros.
Assuming your data is in A1:C6, you can do this with an array formula (enter using Shift+Ctrl+Enter):
=SUM((A1:A6=2011)*(B1:B6>=50)*(B1:B6<=52)*(C1:C6))
Or, with SumProduct (enter as normal):
=SUMPRODUCT((A1:A6=2011)*(B1:B6>=50)*(B1:B6<=52)*(C1:C6))
Obviously, you'll need to enter or reference your criteria. Also, if the year will change then you'll need another term to check the max year.