Creating a formula field - salesforce

I have a picklist field with following values:
1)fall 2019
2)Winter 2019
3)summer 2018
I have one more formula filed in the same object. If an user selects Fall 2019 from the picklist , the formula field should return 8193.
8 - default for all cases
19 - year
3 - value for fall(in the same manner 2 is value for winter and 4 is value for summer).
Please help me to write a formula.

This is how your formula would be:
IF (NOT(ISBLANK(TEXT(Picklist__c))), "8" & RIGHT(TEXT(Picklist__c), 2) &
CASE(LEFT(TEXT(Picklist__c),Find(" ", TEXT(Picklist__c))-1),
"Fall", "3",
"Winter", "2",
"Summer", "4",
"")
, "")
Change Picklist__c with your Pick List field api name.

Related

Google Sheets: ArrayFormula sumifs, but return some symbol or empty cell if there's nothing to sum

I have the following table:
`Jan` `Feb` `Mar`
`P7` `Q7` `R7` 56.80 0 0
`Column E Column I Column N`
17 expense Jan-5 15.87
18 $ Jan-9 56.80
19 expense Feb-8 38.12
20 expense Mar 5 45.38
21 $ Mar-12 0.00
So I have `Cell P7` with the following formula `=ArrayFormula(sumifs(N17:N,E17:E,"$",MONTH(I17:I),1))`
and `Cell Q7` with the following formula
`=ArrayFormula(sumifs(N17:N,E17:E,"$",MONTH(I17:I),2))`
and `Cell R7` with the following formula
`=ArrayFormula(sumifs(N17:N,E17:E,"$",MONTH(I17:I),3))`
that checks `Column I` for January dates (for `P7`), February dates (for `Q7`) and March dates (for `R7`), then checks if there's at least one sign `$` in corresponding `Column E` for those dates, and if there is, sums all corresponding amounts in `Column N`.
Now, my problem is this: the formula, as it is now, returns `0` even if there are no signs `$` for a specific month range, like for February in the above table. There are no `$` sign in `Column E` for February, yet cell `Q7` shows `0`.
I would like it to:
- return nothing at all (empty cell instead of `0`) if there are no amounts in `Column N` for a specific month marked with `$` sign in `Column E`
- return `0` only if there is `0.00` amount in `Column N` along with the `$` sign in corresponding `Column E`.
or
- return something else, like `~`, if there's nothing to sum up.
Let's say for March I could put `$` in `E21` and `~` in `N21` and see that `~` returned in `R7` if there are no more amounts to sum up.
Is there a way to do it?
Thanks to MAttKing's reference, simply add your formula in IFERROR(1/(1/ ComplexFunction() )) which should look something like this.
=IFERROR(1/(1/ArrayFormula(sumifs(D3:D,A3:A,"$",MONTH(B3:B),2))))
Output:

How can I calculate an employee's ID number based on their hire date?

I have a list of employees and want to generate an "Employee ID" based on the Hire Date value. I was hoping to be able to check the Hire Date value and compare it to an array of all the hire dates and to return the correct number.
You can see a list of these dates here: https://docs.google.com/spreadsheets/d/1ogjWzFPWLUECIP9YXL-r7RHM-hPWTPZ-6wX0sTV0QNc/edit?usp=sharing
Ideally, (using a small sampling of the dates above) it would look like the following:
Hire Date Employee ID
3/6/2012 1
3/30/2015 4
8/10/2015 5
8/10/2015 6
9/18/2015 7
9/18/2015 8
6/26/2020 9
3/6/2012 2
2/7/2013 3
use in B1:
={"ID"; ARRAYFORMULA(IFNA(VLOOKUP(A2:A, {SORT(A2:A), ROW(A2:A)-1}, 2, 0)))}
or:
=ARRAYFORMULA(RANK(A2:A, A2:A, 1))
if you want it to not repeat on the same date use:
={"ID"; ARRAYFORMULA(IF(A2:A="",,IFNA(VLOOKUP(A2:A&"z"&
COUNTIFS(A2:A, A2:A, ROW(A2:A), "<="&ROW(A2:A)), {SORT({A2:A&"z"&
COUNTIFS(A2:A, A2:A, ROW(A2:A), "<="&ROW(A2:A))}), ROW(A2:A)-1}, 2, 0))))}

Return dates that are within 1,3,6,12 months from todays date SSRS/Expression

I have a table with the following columns:
Sales | Name | Est.close Date
I'm able to display all dates on one table,
I have created 4 tables , for est. close date next month, 3 , 6, 12 months, what I'm trying to do is display dates that are within 1, 3, 6 and 12 months of today.
I have tried ;
=DateAdd(DateInterval.Month, 6, Parameters!estimateclosedate.Value)
And
=DateAdd(DateInterval.Day, -1 * DatePart(DateInterval.WeekDay,Today()) + 6, Today())
Any help , would be greatly appreciated.Thanks
UPDATE:
I have 2 dates Today() and Fields!estimatedclosedate.Value.
What I'm trying to do is return estimatedclosedates that are within 1,3,6 and 12 months from today.
UPDATE 2:
I have tried
=Fields!estimatedclosedate.Value <> DATEADD(DateInterval.Month,1,Today())
but, this turns a boolean , TRUE.
If you want to show data in different tablixes you should set filter on each tablix.
For example:
In Value for each filter you should set such expressions:
=dateadd(DateInterval.Month, 1, DateTime.Today)
=dateadd(DateInterval.Month, 3, DateTime.Today)
=dateadd(DateInterval.Month, 6, DateTime.Today)
=dateadd(DateInterval.Month, 12, DateTime.Today)
EDIT (after comments)
Try to use this expression in exression field:
=CDate(Fields!estimatedclosedate.Value)
It will solve the problem with date format when convert DateTime to String.

Sum(if) array in Excel 2013 for a range of columns

I have a matrix in Excel with a "Type" in column A and consecutive dates across Row 1.
On each day for each type, the result is either 1 or zero.
My goal is to use a Sum(if) array to sum the values for a particular type for a date range by inputting a start date value in B9 and an end date value in B10 for a specified type ("A", "B", "C") in B8.
Here is the function I've started: {=SUM((A2:A4=B8)*(IF(B1:F1=B9,B2:F4)))}
I'm having difficulty making the function assess the range specified in B9 and B10. Also, you should know that I've used numbers for the day, so use "4" in place of ie 2/4/2015.
Any thoughts?
This formula should help:
=SUMIFS(OFFSET(A1,MATCH(B8,A2:A4,0),1,1,5),B1:F1,">=" & B9,B1:F1,"<=" & B10)
The last parameter in OFFSET function (5) is number of columns in the sum (if the dates are in B1:F1, then it's 5)

sum of squares or square of total?

According to https://newrelic.com/docs/plugin-dev/metric-data-for-the-plugin-api plugins should also report the sum of squares for the specified period. Taking a look at the JSON example, I'd say this is more a square of the total value. E.g.:
{
"name": "Primary MySQL Database",
"guid": "com.your_company_name.plugin_name",
"duration" : 60,
"metrics" : {
"Component/ProductionDatabase[Queries/Second]": 100,
"Component/AnalyticsDatabase[Queries/Second]": {
"min" : 2,
"max" : 10,
"total": 12,
"count" : 2,
"sum_of_squares" : 144
}
}
}
Obviously there were two values, 2 and 10. According to the sample the sum_of_squares is (10+2)^2=144 which I would define as "square of total".
For me however, the term "sum of squares" would be 2^2+10^2=104.
So when taking about multi-value metrics - which one is the correct number?
You're absolutely right that the example values as documented are incorrect. I'll notify the relevant parties to update the documentation.
In the common case where only a single metric value is being reported, the count will be (1), in which case squaring the "total" value yields the correct result.

Resources