Power BI - GroupBy - Top 1 Value (MAX) - group-by

can you help me how I can group by Column 1-7 in Power BI/ DAX and get the Person with the highest Sales based on its group?
I tried groupby in power query and also using the Top Filter N but I can't get the result according to its row grouping from col 1-7.
https://docs.google.com/spreadsheets/d/1DsXO-LunDhe3J5SSgXtzeP6JqlQjnYvu86bLab9tGhM/edit?usp=sharing

Here's the Calculated Table formula you are looking for:
Result =
SUMMARIZE(
'Raw Data',
'Raw Data'[Column 1],
'Raw Data'[Column 2],
'Raw Data'[Column 3],
'Raw Data'[Column 4],
'Raw Data'[Column 5],
'Raw Data'[Column 6],
'Raw Data'[Column 7],
"Person", CALCULATE(
MIN('Raw Data'[Person]),
'Raw Data'[Sales] = MAX('Raw Data'[Sales])
),
"Sales", MAX('Raw Data'[Sales])
)

Related

[apache-spark][GraphX]Is there a global vertex aggregation function in GraphX?

Is there a global vertex aggregation function in GraphX? I hope this function can calculate the number of different values of vertex attributes, like the 'collections.Counter' function in Python.
For example, I have a graph like: (Each line represents a vertex, weight of each edge = 1)
[source vertex, source vertex some-attrbute-value, [dst vertex1, dst vertex2, ...]]
{
[1, 1, [2, 3]]
[2, 1, [1, 3, 4]]
[4, 1, [2, 3]]
[3, 1, [1, 2, 4]]
[5, 2, [4, 6, 7]]
[6, 2, [5, 7]]
[7, 2, [5, 6]]
}
and the output looks like following:
{1: 4, 2: 3}
or the vertexId_list could be given (better!) like followings:
{1: [1, 2, 3, 4], 2: [5, 6, 7]}
What's more, it's perfect if this function can work together with PregelAPI. For example, Pregel control the stop point by using this function: When the number of some vertex-attr-value reach the threshold(for example, the number of value 1 = 4(There are 4 vertex which attrbute = 1)), the superStep stops.
P.S. This function should seems like "AggregatorXXX(vertex) -> Message or Sth", not the RDD-relative method, like filter/map, etc.
Sorry for my poor English. :)..

Error Encountered: Value is not valid number: B2 Parameter name: serialDate

I'm trying to create my own calculation in RSA Archer. I'm comparing to Date fields.
Sample calculation:
Field name Field Type
Field 1 Date
Field 2 Date
Field 3 Values List
IF(DATEDIF([Field 1], [Field 2]) > 0, VALUEOF([Field 3], "Green"),
IF(DATEDIF([Field 1], [Field 2]) > 1, VALUEOF([Field 3], "Amber"),
IF(DATEDIF([Field 1], [Field 2]) > 3, VALUEOF([Field 3], "Red"),
VALUEOF([Field 3],"Not Calculated"))))
But unfortunately, I encountered an Error.
Can anyone help me fix this error message or can someone suggest a better way to manipulate this calculation?
The calculation you shared has a missing round bracket ")" at the end. You have 3 "IF" and only two closing brackets. So calculation you shared should fail validation in Archer formula editor.
The error you shared indicates an issue with one of the input fields: [Field 1] or [Field 2]. I see two possible issues:
a). Confirm that [Field 1] and [Field 2] are actually of the Date type. In some cases field time may be Text and calculation can fail.
b). You need to check in calculation and make sure that both fields are not empty. I would modify the calculation as such:
IF( OR(ISEMPTY([Field 1]), ISEMPTY([Field 2])), VALUEOF([Field 3],"Not Calculated"),
IF( DATEDIF([Field 1], [Field 2]) > 0, VALUEOF([Field 3], "Green"),
IF( DATEDIF([Field 1], [Field 2]) > 1, VALUEOF([Field 3], "Amber"),
IF( DATEDIF([Field 1], [Field 2]) > 3, VALUEOF([Field 3], "Red"),
VALUEOF([Field 3],"Not Calculated")
))))

How to set data in chart with interval?

I use Google Chart API.
My array contents some parameters for displaying:
var rawData = [
[{v: [8, 0, 0], f: '03/02/13'}, 1],
[{v: [9, 0, 0], f: '04/02/13'}, 2],
[{v: [10, 0, 0], f:'05/02/13'}, 3]
];
How to display only one title for 3 element no all from array?
It's hard to tell from the wording of the question, but I think you're looking for something like a Data View? They allow you to filter a data table. Select only certain rows or columns, etc. If you only ever have the 3 rows you might also consider just having an array of 3 DataTables and cycling through them, redrawing the chart for each.

How to see the contents of each partition in an RDD in pyspark?

I want to learn a little more about how pyspark partitions data. I need a function such that:
a = sc.parallelize(range(10), 5)
show_partitions(a)
#output:[[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]] (or however it partitions)
The glom function is what you are looking for:
glom(self): Return an RDD created by coalescing all elements within each partition into a list.
a = sc.parallelize(range(10), 5)
a.glom().collect()
#output:[[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]
val data = List((1,3),(1,2),(1,4),(2,3),(3,6),(3,8))
val rdd = sc.parallelize(data)
rdd.glom().collect()
.foreach(a => {
a.foreach(println);
println("=====")})
in this way , you can check how the data is partitioned

Prolog: dividing a number

I wanted to make a predicate that returns a list of a number dividers.
Example: 72 = 2*2*2*3*3.
prdel(A,[],_):-
A is 1.
prdel(P,[D|L],D):-
0 is mod(P,D),
P1 is P/D,
prdel(P1,L,D).
prdel(P,L,D):-
D1 is D+1,
prdel(P,L,D1).
This works and returns the right list. The problem is that it does not stop after that but returns the same list over and over again if I press space (I am sorry I don't know the term in English when you use the same predicate to get different answer). I want it to stop after the first time.
I tried to edit the last one like that,
prdel(P,L,D):-
D1 is D+1,
D1<P,
prdel(P,L,D1).
but now it returns only false and not the list.
EDIT:
I am looking for an answer without cut.
One problem in your code is that it keeps trying to divide the number P by D even when it is clear that the division is not going to succeed because D is too high. This lets D "run away" without a limit.
Adding a check for D1 to be below or equal to P fixes this problem:
prdel(1,[],_).
prdel(P,[D|L],D):-
0 is mod(P,D),
P1 is P/D,
prdel(P1,L,D).
prdel(P,L,D):-
D1 is D+1,
D1 =< P,
prdel(P,L,D1).
This produces all combinations of divisors, including non-prime ones (demo).
[[2, 2, 2, 3, 3], [2, 2, 2, 9], [2, 2, 3, 6],
[2, 2, 18], [2, 3, 3, 4], [2, 3, 12], [2, 4, 9],
[2, 6, 6], [2, 36], [3, 3, 8], [3, 4, 6], [3, 24],
[4, 18], [6, 12], [8, 9], [72]]
If you do not want that, add the condition that mod(P,D) > 0 in the last clause:
prdel(1,[],_).
prdel(P,[D|L],D):-
0 is mod(P,D),
P1 is P/D,
prdel(P1,L,D).
prdel(P,L,D):-
mod(P,D) > 0,
D1 is D+1,
D1 =< P,
prdel(P,L,D1).
This produces only [2, 2, 2, 3, 3] (demo).