Is there a way to update sum of row in 2D array? - algorithm

Let's say I have a 2D array in Java. Is there a way such that if I have calculated the sum of a row and I change a few values in that row, the value of the sum is updated automatically? Is it possible too in C ?

Build a listener which will listen to changes in the 2D array. If any value gets changed, the listener will trigger a method which will update the sum.
Take a look at the DefaultListModel. You can use the fireContentsChanged method to specify the actions you want to take when values get changed.
I don't know if C has something like this. Maybe you can write your own Listener.

Related

Qlikview - show first and last selected value in list

I need to display first and last selected value in list. I have listbox and when I pick date I got this result in list
I want to get in one box min value selected but when I use minString(Data) I got 22/2022 instead 303/202. And for max I need to get 306/2022.
Can anyone help please?
To get the Qlik engine to ignore the selected values you need to set analysis.
Firstly, you should be using a max() not a maxstring(). Max() will evaluate the maximum numerical value. Maxstring() will evaluate the maximum ascii values of the string (I think, anyone can correct me).
Secondly, the value 306/2022 in that list is grey which means it is no longer included in the dataset used for the visualisations being displayed. The white values are the values that are included, this is why min(Date) is returing 22/2022. 22/2022 is the minimum available (white) value in that list. 303/2022 is the minimum value of the excluded values in grey.
If you want to be able to reference the values even when the selections have caused it to be excluded (turned them grey) you need to modify your max() to max({1}).
{1} means look at all the data not just the selected data.
max({1} Date)
will return 306/2022 no matter what the selections are.
If you want to return 303/2022. The minimum of the excluded values and have that change dynamically when making other selections let me know and I can show you but I will require you to explain why you would want to that before I try figure it out :)
You can try using the OnOpen document trigger.
enter image description here

Sum value flow power automate

I have a table on azure following :
enter image description here
Can anyone help me to make a sum perday of number of users with flow power automate :
enter image description here
Thanks in advance
Ok, this is a monster of an answer but it works so follow closely.
Refer to the images for what to do.
The basic concept is, loop through all entities and fill an array with the distinct row keys. The way we determine if it's distinct or not is by adding the row key to an array IF it hasn't been added previously.
From there, we will loop through that distinct list and using an inner loop, we will sum each NumberOfUsers column IF the Inner Row Key matches the Outer Row Key that is being processed.
At the end of the outer loop, add an object to an array. That object has two fields, "RowKey" and "NumberOfUsers". The "NumberOfUsers" field contains the summation for that given RowKey.
From here, you have the distinct count.
If I've mis-used any fields (i.e. the use of RowKey) then change it up as need be.
This is just logic, you just need to apply it to the scenario. I think this is best done in an Azure Function because it'll run faster and be a lot less to maintain but if you want to avoid that and use PowerAutomate, this works.
Flow
Data / Table
Result

Is it possible to have a constant value in a calculated field in 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

Is it possible to get the last row filled?

In gspread, is it possible to get the last row or cell number that is filled?
The API reference page doesn't seem to help.
Gspread has "row_count", but I am not sure it returns all rows in a spreadsheet, or just the filled ones. If that doesn't help, there is a slightly less direct, but completely functional way to do it:
1.) let's assume your data is in column A, and it has been filled in consecutively row by row (i.e. no skipped rows)
2.) in another free cell in your spreadsheet--let's assume cell B1--use the native Google Sheets function COUNTA, which will count the number of values in a dataset, and specify column A as the target, i.e. "=COUNTA(A:A)"
3.) now just request the value of cell B1 with gspread's acell, i.e. "last_row_updated = myWorksheet.acell("B1").value"
You can use the following code, taken from this answer to this similar question:
def last_filled_row(worksheet):
str_list = list(filter(None, worksheet.col_values(1)))
return len(str_list)

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