I am pretty new to PowerBI and cannot figure out a way to compare two values in two columns. All I need is a columns that says True or False. This would be pretty easy in Excel but I am sure there is a way in PowerBI as well?
My data looks like this:
Number
Type
Size
PO1
5
10
PO1
6
12
PO2
5
09
PO2
6
10
PO3
5
10
PO3
6
10
Which I organise to look like this in a matrix (not exactly this formatting but I don't know how to show this, but it's a matrix):
Number
Type 5
Size
Type 6
Size
PO1
5
10
6
12
PO2
5
09
6
10
PO3
5
10
6
10
And I want to know:
Number
Type 5
Size
Type 6
Size
Same size
PO1
5
10
6
12
False
PO2
5
09
6
10
False
PO3
5
10
6
10
True
You could solve this with a calculated table like:
Comparison =
SUMMARIZE(
'Table',
'Table'[Number],
"Same size", MIN('Table'[Size]) = MAX('Table'[Size])
)
which will look like this in a table visual:
What I did was Transform the data as follows:
Number as index column
Min size as 'input'
Max size as 'output'
New column comparing input and output
Save and Run
Related
Below is a SAS proc Mixed code generated by JMP. Both JMP and SAS give me a confidence interval for the variance components (in the table "covariance parameter estimates"). I would like the degrees of freedom in the output, or at least a formula to calculate them. Can anyone tell me where that would be?
DATA Untitled; INPUT x y Batch &$; Lines;
0 107.2109269 4
3 106.3777088 4
6 103.8625117 4
9 103.7524023 4
12 101.6895595 4
18 104.4145268 4
24 100.6606813 4
0 107.6603635 5
3 105.9161433 5
6 106.0260339 5
9 104.660272 5
12 102.5820776 5
18 103.7961511 5
24 101.2887124 5
0 109.2066284 6
3 106.9341754 6
6 106.6141445 6
9 106.8234541 6
12 104.7778902 6
18 106.0184734 6
24 102.9822743 6
;
RUN;
PROC MIXED ASYCOV NOBOUND DATA=Untitled ALPHA=0.05;
CLASS Batch;
MODEL y = x/ SOLUTION DDFM=KENWARDROGER;
RANDOM Batch / SOLUTION ;
RUN;
i'm currently solving a problem that states:
A company filed for bankruptcy and decided to pay the employees with the last remaining valuable items in the company only if it can be distributed evenly among them so that all of them have at least received 1 item and that the difference between the employee carrying the most valuable items and the employee carrying the least valuable items can not exceed a certain value x;
Input:
First row contains number of employee;
Second row contains the x value so that the the difference between the employee carrying the most valuable items and the employee carrying the least valuable items can not exceed;
Third row contains all the items with their value;
Output:
First number is the least valuable basket of items value and the second is the most valuable basket;
Example:
Input:
5
4
2 5 3 11 4 3 1 15 7 8 10
Output:
13 15
Input:
5
4
1 1 1 11 1 3 1 2 7 8
Output:
NO (It's impossible to distribute evenly)
Input:
5
10
1 1 1 1
Output:
NO (It's impossible to distribute evenly)
My solution to resolve this problem taking the first input is to, sort the items in ascending or descending order so from
2 5 3 11 4 3 1 15 7 8 10 --> 1 2 3 3 4 5 7 8 10 11 15
then create an adjacency list or just store it in simple variables where we add the biggest number to the lowest basket while iterating the item values array
Element 0: 15
Element 1: 11 <- 3 (sum 14)
Element 2: 10 <- 3 (sum 13)
Element 3: 8 <- 4 <- 1 (sum 13)
Element 4: 7 <- 5 <- 2 (sum 14)
So that my solution will have O(nlogN + 2n), first part using merge sort and then finding max e min value, what do you guys think about this solution?
Given a grid of dimensions A*B with values between 1-9, find a sequence of B numbers that maximizes the minimum number of values matched when compared with A rows.
Describe the certain steps you would take to maximize the minimum score.
Example:
Grid Dimension
A = 5 , B = 10
Grid Values
9 3 9 2 9 9 4 5 7 6
6 3 4 2 8 5 7 5 9 2
4 9 5 8 3 7 3 2 7 6
7 5 8 9 9 4 7 3 3 7
2 6 8 3 2 4 5 4 2 2
Possible Answer
6 3 8 2 9 4 7 5 7 4
Score Calculation
This answer scores
5 when compared with Row 1
5 when compared with Row 2
1 when compared with Row 3
4 when compared with Row 4
2 when compared with Row 5
And thus the minimal score for this answer is 1.
I would go for a local hill-climbing approach that you can complement with a randomization to avoid local minima. Something like:
1. Generate a random starting solution S
2. Compute its score score(S, row) for each row. We'll call min_score(S) the minimum score among all rows for S.
3. Attempt to improve the solution with:
For each digit i (1..B) in S:
If i belongs to a row such that score(S, row) > (min_score(S) + 1) then:
Change i to be the digit of a row with min_score(S). If there was only one row with min_score(S), then min_score(S) has improved by 1
Update the scores of all the rows.
If min_score(S) hasn't improved for more than N iterations of 3, go back to 1 and start with a new random solution.
In Kibana's visualize screen I'm trying to create a "sum" metric and I would like to limit the values of this sum (between 0.1 and X), but I only get to limit the field values before aggregation is performed.
I have designed a simple metric that consists in the aggregation of a field called Timestamp_Med. I don't know how to make the filter properly,
so I only get the filter applied on the field, but not on the sum metric.
For example, if I have these rows:
ID Session_Id Timestamp_Med
1 1 5
2 1 7
3 1 3
4 2 6
5 3 0
6 3 2
7 4 15
8 5 4
9 6 0
10 6 4
My metric must sum the Timestamp_Med field, group by the Session_Id
Session_Id Sum(Timestamp_Med)
1 15
2 6
3 2
4 15
5 4
6 4
I apply the filter: (Timestamp_Med: [1 TO 5]) I get the results for the original records with ID 1,3,5,6,8,9 and 10 with the next session values for the metric:
Session_Id Sum(Timestamp_Med)
1 8
3 2
5 4
6 4
But I want to filter values in "Sum(Timestamp_Med)", not in "Timestamp_Med", and get:
Session_Id Sum(Timestamp_Med)
3 2
5 4
6 4
Could I do this filter? Is it possible?
Thank you.
I have a matrix and I want to find the maximum value in each column, then find the index of the row of that maximum value.
A = magic(5)
A =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
[~,colind] = max(max(A))
colind =
3
returns colind as the column index that contains the maximum value. If you want the row:
[~,rowind] = max(A);
max(rowind)
ans =
5
You can use a fairly simple code to do this.
MaximumVal=0
for i= i:length(array)
if MaximumVal>array(i)
MaximumVal=array(i);
Indicies=i;
end
end
MaximumVal
Indicies
Another way to do this would be to use find. You can output the row and column of the maximum element immediately without invoking max twice as per your question. As such, do this:
%// Define your matrix
A = ...;
% Find row and column location of where the maximum value is
[maxrow,maxcol] = find(A == max(A(:)));
Also, take note that if you have multiple values that share the same maximum, this will output all of the rows and columns in your matrix that share this maximum, so it isn't just limited to one row and column as what max will do.