Selecting certain values in dataset and changing their values - sparklyr

I have the tbl format dataset for my project and I have one column where I have mixed values (although I can differentiate which are which) and I want to change the selected values of that column by dividing them by certain number, what is my best approach for this?
I have thought of writing mutate and somehow applying if statements inside but I couldn't figure out how to do it.

By leveraging the dplyr package, you can do
mutate_if(condition_to_check, funs(. / number_to_divide_by))

Related

Writing a formula in a cell in Google Sheets that averages the results from a column derived from expected values in multiple columns

I'm an average user of Google sheets and I've tried writing/looking up the formula I'm going for, but I haven't had any luck yet.
I have a spreadsheet that details multiple values that I need to display in a single cell the average of a certain set of values derived from a specific set of those values from multiple columns.
The flow of information would look something along the lines of:
if value in Column D=L
then
if value in Column J<$1.20
then
Find Avg of all Values in Column N
I'd need the formula to narrow it's field of data each time so the final result was the average of all the values in Column N that had a value in column J<$1.20 with a value in Column D=L.
I feel like a dummy over here because I just can't narrow down how I should write this flow and get it to work right without adding multiple extra hidden columns. Can anyone help on this one?
I've tried writing the formula multiple different ways but haven't kept it written down to pass on.

BIRT suppress multiple duplicate columns

I am working on a BIRT report. Its records are grouped on the basis of the status column. I was looking for an option in the Eclipse BIRT tool by which I can hide combinations of multiple columns in a row which are repeating. I have attached screenshots for both the current report and the expected report structure.
I tried the "suppress duplicate" option but that is limited to a single column. I am not able to apply this on multiple columns together. I couldn't figure out any other option. Please suggest any solution in the tool or do I need to change my query to return the result in the expected format?
Actual Result:
Expected Result:
There are three obvious ways to hide duplicate values.
All of these require you to configure this per column (BTW I don't understand why you consider this to be a problem).
As you already did: Use "suppress duplicates" at the column level.
Add more groups to your table after the existing group.
E.g. one group for the first column (whatever that is).
Then you can choose "Drop" "detail" in the properties of the corresponding group header cell. It's a bit difficult to get the layout right this way.
In your data set, if it's SQL, you can use a little construnct with CASE and the LAG analytic function to compare the column value to that of the previous row, and if they are equal, return NULL instead (pure SQL solution).

Arrange imported columns after calculated columns in PowerBI

Is there a way to move imported columns after calculated columns? I know I can create a new table by using Selectcolumns, but that'll just balloon the size of the PowerBI data file. Seems like such a miss on Microsoft's part
No there is no way to. I would avoid calculated columns and instead create the additional columns in Power Query which will eliminate your problem anyway.
Simply start all calculated columns with an underscore (judging by your username, you seem to be fond of unnecessary underscores)
Another option would be to put imported and calculated columns into different Display folders (such a miss on user's part)

Power Query - conditional replace/clear entire cell in multiple columns

I'm trying to clear the entire cell if it doesn't contain a given keyword.
I've managed to do this for one column:
Table.ReplaceValue(#"PrevStep",each [#"My Column"], each if Text.PositionOf([#"My Column"],"keyword")>-1 then [#"My Column"] else null,Replacer.ReplaceValue,{"My Column"})
The problem is I need to iterate/repeat that step for a number of columns... the number of columns may vary and column names also may be different every time. I can have all those column names put into a list but I'm not able to use it.
The solution I'm looking for may look like this
for each ColNam in MyColumnsList
Table.ReplaceValue(#"PrevStep",each [#"ColNam"], each if Text.PositionOf([#"ColNam"],"keyword")>-1 then [#"ColNam"] else null,Replacer.ReplaceValue,MyColumnsList)
next
but this is not the VBA code but Power Query M - and of course the problem is with #PrevStep as I would see it like a recursions... again... do not know how to process.
Is the path I follow correct or should it be done some other way
Thanks
Andrew
Unpivot your columns to turn all the columns into two columns. Apply your replacement to the single value column then pivot it back into the original format

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

Resources