Creating a measure from two columns present in two different fields [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 days ago.
Improve this question
I am new to Power BI. I know how to create a measure between two columns present within a field. But how do I create a measure from two different columns present in two different fields (IVIGUsage and TargetvsActuals?
I need to create a measure for gram variance and grams to target. So, could you please help me out? Earlier I had created the measure based on the one field targetvsactual which are as:
%GM_Target = Calculate(
DIVIDE(
Sum('TargetVsActuals'[Total_Grams]),
SUM('TargetVsActuals'[Target_Grams])))
Gram Variance = (Sum('TargetVsActuals'[Target_Grams]) - Sum('TargetVsActuals'[Total_Grams]))
So, this has to be modified. Please help me out.

Related

Is there a faster way to add new column data with hundreds of rows? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 11 months ago.
Improve this question
I have a decent-sized table 'countries' with about 10 columns. I recently added a new column to the table 'GDP' and I am entering the information per row using
UPDATE countries
SET GDP=(value)
WHERE name = (country);
I have 200 countries in this table. Is there a better way to update this information?
This project is from Khan Academy. We are asked to select a database and run queries on it. The data was pulled from https://gist.github.com/pamelafox/ad4f6abbaac0a48aa781
I am just making sure that there isn't a more efficient way of adding this information to the existing table 'countries' where the primary key is the name of the country.

Need RegEx to filter dataset according to specific position in string [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Want to filter dataset with SQL query using RegEx to filter entries based on the time (hour) e.g. 19:XX or 09:XX. The hour part of the string would be in position 12 and 13.
Checked a few other questions and articles, but I'm very new to this and can't figure it out. Don't know which SQL database it is, but I work with it on Google BigQuery.Thanks for your help!
Screenshot of data entries
The standard way to access the hour in a date/time is:
where extract(hour from timecol) = 19
Not all databases support extract. All should have something similar.

Plotting data R [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a simple tasks I would like to do. Using an RODBC connection I have connected R to a SQL server database. There are four tables in the database and they are tenors of Libor rates
Libor_1_mos
Libor_3_mos
Libor_6_mos
Libor_12_mos
Each table has two columns. The first column shows dates and the second column shows rates.
I would like a simple chart that plots the rates based on the dates in column 1. Straightforward - that is all that needs to be done. The x-axis should be dates (column 1) and the y axis should be rates (column 2). Note it is 5 years worth of data so showing every possible date on the x-axis may not be feasible.
Here is my work so far I am using the Libor_3_mos as an example
threemosdata <- sqlQuery(con,"select * from Libor_3_mos)
Using that line I can read the data from the table. So for instance
colnames(threemosdata)
will give me the names of the column in the table.
So this worked lovely
> date <- (threemosdata$observation_date)
> rates <- (threemosdata$USD3MTD156N)
> plot(date,rates)

In Oracle SQL, how do I find where a column may be referenced using just queries? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a specific column, called DELIVER_TO_LOCATION_ID , which is in a table called apps.po_requisition_lines_all
I need to dig into the database and derive the continent from the DELIVER_TO_LOCATION_ID ,
In SQL Developer I can't seem to find a way to do this .
any tips appreciated. thanks
You can use following command-
desc tableName
It'll give you description of table including every column in it having any constraints on it or not like primary key, reference key etc.

How to choose between two items based on a percentage in Objective-C? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am trying to figure out how to choose between two things based on a percentage, but I don't know how to code it correctly. I am trying to choose between item a and item b when the chance of item a being chosen is 33.33% and item b is 66.67%. I'm not sure if I should use if else statements or something else. I would like to know how to code it in objective c, but any advice would be helpful.
Thanks
If the percentages are fixed, it's quite easy:
int result = (arc4random_uniform(3) == 0) ? a : b;
Essentially, this says "if a uniformly distributed non-negative integer strictly less than 3 is exactly equal to 0 (which happens 1/3 of the time), then the value of this expression is a, else it is b".