Is it possible to have a constant value in a calculated field in QuickSight? - amazon-quicksight

In QuickSight, when you want to define a constant value to reuse it in visualizations later, you can try to set it as:
Calculated field: goalFor2020
Formula: 20000
But right now it doesn't allow you to put just a number in the formula.
Is there any way to do achieve having just a number in the formula of a calculated field?
The reason we need it is just to have a number that doesn't depend on any data, just manually defined by us.

Interesting, QuickSight lets me insert a number into a calculated field, just fine.
Since that isn't working for you, I'd recommend using a parameter with a default value. For example,
Parameters essentially has the same "rights" as a calculated field (it can be used in visuals, other calculated fields, etc...). It can also be passed via query parameters which may or may not be a feature that you'd find useful.
Another cool benefit of using parameters is that, if you're embedding QuickSight, you could retrieve this value dynamically and pass it to the dashboard. Then if you wanted to, say, generalize your for different yearly goals, the goal could be passed and dynamic (rather than hard-coded in a calculated field).

We could achieve it with a trick, just apply some function that returns a number to one of your columns, and make it 0, then add your constant number:
Calculated field: goalFor2020
Formula: count(email) * 0 + 20000
It does the trick, but there might be a better way to do it.

I have tried something like this:
distinct_countIf({dimension},{dimension}='xxx')*
+distinct_countIf({dimension},{dimension}='xxx')*
just makes the discount_countif meet the requirement, so it will return to 1. And use 1* the number you want to hardcode. If the requirement does not meet, it will return 0 so it won't add up the number

Related

Is there a faster way to increase/decrease a value besides using scripts in Google Sheets?

https://docs.google.com/spreadsheets/d/1wgapukUmnkgW3qZLqZ8I-FgRI1kCBw4tYGNBJnxIv_Q/edit?usp=sharing
You can see I created up and down arrows that are used to increase/decrease the percentages in column H.
It's a little bit slow because it's run by a script. Is there a faster way to do this?
You can use Data Validation for the values in your I column
The formula for your named range could be
=ArrayFormula(SEQUENCE(11,1,14,2)/100)
As for the Data Validation you can use List from a range and use my_percentages.
Using the combination of Named ranges and Data validation will give you instant results.
(Make a note that the named range can be anywhere. Even in a new tab.)
Functions used:
ArrayFormula
SEQUENCE

elasticsearch fill gaps with previous value

I have time series data in Elasticsearch and I want to aggregate it to create histogram. What I want to achieve is to fill the null buckets with the value of the previous data point. I know that I can use min_doc_count: 0 but it will put the value as 0 and I couldn't find any out of the box way to do this via Elastic. May be there is some trick that I am not aware of?
Appreciate your feedback.
I think the Date Histogram Aggregation does not provide a native way to perform what you would like.
The closest thing I can think of is using missing value. However, this will set a static value to all the dates where no values are found, which is not exactly what you want.
I also thought of using Painless with the following logic:
Get the first value in the Histogram and store it in a variable current.
If the next value is different to 0, store this value to current.
If the value is 0, set the current value to the histogram date. Don't change current.
Repeat step 2 until you finish the Histogram.
Using painless, in my experience is really painful but you can consider it as an alternative.
Additionally, I would recommend you to limit ES to perform searches and aggregations. If you require additional logic to the output, consider performing it outside ES. You can use the Python ES Client for instance.
I can think of the following script with a similar logic as the Painless scenario:
current = 0
results = es.search(...)
for i in res["aggregations"]["my_histogram_name"]["buckets"]:
if not i["doc_count"]: #this is the same as "if i["doc_count"]==0"
i["doc_count"] = current
current = i["doc_count"] #changed or not, we always use the last value to current
After that, the histogram should look as you want and ready to be displayed.
Hope this is helpful! :)

Is it possible to multiply by -1 in a CRM Dynamics 2016 Workflow?

I'm trying to create a workflow that would make the target field value a negative number. I want to create related records as credits and debits and then be able to sum them up to get a net value.
I've tried to update the field to -1 and then multiply it accordingly, but I get an error stating that the value needs to be between 0 and 1,000,000,000,000. I've also just tried to multiply the value by a -1, but that doesn't work either. It just runs the workflow, but doesn't change the value.
Building on the comment from #MarioZG it looks like your CRM field doesn't allow negative numbers.
When you setup a number field (Decimal; Currency; Floating or Whole Number) you can specify the range of acceptable values. Here's a quick screenshot of the Whole Number's properties:
I actually figured this one out. I created two different workflows to create records in one entity with different "Types". Then, on the account I had a rollup field to sum one type and then a rollup type to sum the other type. Then I used a calculated field to subtract one from the other.
Use data type of the field as decimal number(looking at your use), in this case you will have flexibility of storing all sort of numbers.

Column not defined in current context

I'm trying something very simple in DAX:
[Balance] := 'Inventory'[Inventory Amount]*10
I get a "column does not exist in current context" error. What does this mean?
You are getting this error because it was expecting an aggregate. You are creating a calculated measure but referring to a row and it doesn't have context for this row. I'm not sure what you are trying to achieve. If you need to calculate things on a row level, you'll need to use a SUMX (or you need to create a calculated column that multiplies the Inventory Amount column by 10 and then SUM it. Otherwise, you can use SUM with just one calc.
If you just need to add all the inventory amounts on every row in the query context and then multiply by 10, you can do
Balance:= SUM('Inventory'[Inventory Amount])
If the number you multiple will not always be 10, I suggest putting that formula in a separate calculated column (let's call it 'Inventory[Factor]. Then create a calculation like:
Balance:= SUMX('Inventory', 'Inventory'[Inventory Amount] * 'Inventory'[Factor])
The difference between these two is that the SUM will do the aggregation first. The SUMX will do the row-level calculation first and then aggregate. Since I don't know what you are trying to do, I gave you both options. SUMX will probably be slower, so you probably want to avoid that.
Here is a relevant blog post on the subject. In general check out PowerPivotPro.com and DaxPatterns.com when trying to find your way through DAX.

Is it possible to have a binding that combines more than one key path?

Lets say I have an object which has a quantity value.
Also, I have an array controller which holds an array of these objects.
Furthermore, I have a table which has a percent of total column (i.e. the given row's quantity's percentage of the sum of the quantities for all rows), which needs to be populated with the proper value via bindings.
It would then seem that the idea way to do this would be to bind this column to arrayController.arrangedObjects.#sum.quantity divided by arrayController.arrangedObjects.quantity.
Is it possible to do this?
If not, can you suggest an alternative means of achieving this same end?
One way would be to implement a custom number formatter, with a custom binding for the divisor, programmatically bound to arrayController.arrangedObjects.quantity. In the formatter's setObjectValue: method, you would perform the division and pass the result to super.

Resources