How can I compare the properties of a vertice, to the properties of another vertice - azure

I'm using Gremlin to interact with a Graph in CosmosDB.
I have some data about employees, data they have access to and departments where both originate from. See below for an example.
I want to retrieve information from my graph about which employees have access to data, but doesn't belong in their department. Basically, I want to see where the department columns are not equal, but the column data_access and data_id are equal, for every database the employee has access to. From the example below I would return information employee_id 1 and 2.
employee_id
name
department
data_access
1
john
A
4
2
rick
B
5
3
nick
A
5
dataset_id
name
department
4
apples
B
5
oranges
A
So far I tried to construct queries using traversal steps like "has", "as", "where" but I couldn't achieve the result I want. I'm very new to Gremlin, so I have no idea if what I'm doing is even the right way to do it.

Related

How do I stop Power BI from repeating the unique ID in a table?

I am pulling data (which I have no control over) into Power BI via direct query. I know that this data has repeating values in several columns, but my unique ID is the project that one or more people are working on together. My table visualization has columns for ProjectID, KeyPersonnel, ProjectStatus, and ProjectTitle. I want to organize the table by ID and list all personnel in the second column. Unfortunately, my table is instead repeating the ID with a row for each person on the project.
For example:
ProjectID
KeyPersonnel
ProjectStatus
ProjectTitle
190884
Smith, John
Complete
"Random Title"
190884
Doe, Jane
Complete
"Random Title"
190892
Bush, Kate
In Progress
"Other Title"
I want it to look like this:
ProjectID
KeyPersonnel
190884
Smith, John; Doe, Jane
190892
Bush, Kate
I have tried switching to a matrix, with ProjectID under rows and everything else under values, but that just forced my users to click on the + symbol to view more than the first person named and it still showed repeating rows.

Pivot table showing too many rows with DAX measure

Consider the following two tables
Major
Major Department
Department Name
Department Number
Produce
Produce
2
Produce
Taxable Produce
3
Frozen
Frozen
5
Grocery
Grocery
1
Grocery
Taxable Grocery
10
and Sales
UPC
Department
Category
SubCategory
Sales
1125
2
Fruit
Oranges
20
8256
5
Frozen Treats
Fruit Bars
15
9230
1
Snacks
Chips
28
4018
2
Fruit
Bananas
10
925
2
Vegetables
Onions
9
A relationship is created between the Department and Department Number columns.
I create the following pivot table:
What I want to do is add a measure which shows the total for the Major Department on each row.
I have tried MajorDepartmentSales:=CALCULATE(SUM(Sales[Sales]),ALL(Sales[SubCategory]),ALL(Sales[Category]))
which should remove the filters on category and subcategory. I would expect this to work, however it adds every category under the major department, but with the correct values.
Note, that the value of this measure is correct. It shows the totals under that particular major department. The problem is that it shows every category and subcategory under each major department whether they belong there or not. Why is this?
I have found two ways around this. The first modifies the measure to IF(COUNT(Sales[UPC])>0,CALCULATE(SUM(Sales[Sales]),ALL(Sales[SubCategory]),ALL(Sales[Category])),BLANK()) which checks if there are any items under that particular row, and blanks it out otherwise. The second method is to pull the major department to the Sales table with a calculated column MajorDepartmentOnSales:=Related(Major[Major Department]) and then using this column in the pivot table instead of the major department from the Major table.
Both produce what I want. The IF method seems a bit sketchy to me, however.
Question
My question is then why do I get these extra rows in the original approach?
It seems that DAX is correctly recognizing which major department is in play as it gets the value correct, but it is not recognizing that when it comes to filtering it out of the pivot table. I am really new to DAX, and it seems that I am not understanding something either in how the relationship is propagated down or how power pivot interacts with the pivot table.
How do I solve this? Is there a way to rewrite the measure to not cause these extra rows, or do I have to use one of these alternative methods? Ideally, I don't want to change the model. (The actual data in the real report has more tables and more (slightly different) columns than this example, but the example recreates the essential issue.)
Internal engin produce a cross-join for this combination of column/measure:
SELECT {[Measures].[Sum of Sales],[Measures].[MajorDepartmentSales]}
DIMENSION PROPERTIES
PARENT_UNIQUE_NAME,MEMBER_VALUE,HIERARCHY_UNIQUE_NAME ON COLUMNS , NON
EMPTY
Hierarchize(DrilldownMember(DrilldownMember(CrossJoin({[Table1].[Major
Department].[All],[Table1].[Major Department].[Major
Department].AllMembers},
{([Table2].[Category].[All],[Table2].[SubCategory].[All])}),
[Table1].[Major Department].[Major Department].AllMembers,
[Table2].[Category]), [Table2].[Category].[Category].AllMembers,
[Table2].[SubCategory])) DIMENSION PROPERTIES
PARENT_UNIQUE_NAME,MEMBER_VALUE,HIERARCHY_UNIQUE_NAME ON ROWS FROM
[Model] CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR,
FORE_COLOR, FONT_FLAGS
If you add a Sales[Department] then you get correct results (what you are expecting), Engine still produce a crossjoin (because of ALL() in measure) but also add a Department (out of crossjoin scoope) and corect relationship are used:
SELECT {[Measures].[Sum of Sales],[Measures].[MajorDepartmentSales]}
DIMENSION PROPERTIES
PARENT_UNIQUE_NAME,MEMBER_VALUE,HIERARCHY_UNIQUE_NAME ON COLUMNS , NON
EMPTY
Hierarchize(DrilldownMember(DrilldownMember(DrilldownMember(CrossJoin({[Table1].[Major
Department].[All],[Table1].[Major Department].[Major
Department].AllMembers},
{([Table2].[Department].[All],[Table2].[Category].[All],[Table2].[SubCategory].[All])}),
[Table1].[Major Department].[Major Department].AllMembers,
[Table2].[Department]), [Table2].[Department].[Department].AllMembers,
[Table2].[Category]), [Table2].[Category].[Category].AllMembers,
[Table2].[SubCategory])) DIMENSION PROPERTIES
PARENT_UNIQUE_NAME,MEMBER_VALUE,HIERARCHY_UNIQUE_NAME ON ROWS FROM
[Model] CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR,
FORE_COLOR, FONT_FLAGS
You can use such a workaround.
=IF(ISBLANK(SUM(Table2[Sales])); BLANK(); CALCULATE(SUM(Table2[Sales]); ALL(Table2[SubCategory]; Table2[Category])) )

Group comma seperated values in a row and create a new pandas column

I have a situation where I need to create a new pandas column based on the comma separated values that are present in the corresponding using some matching of the phrases.
For examples: My data frame looks like this :
ID INFORMATION
1 HR, MGMT, Leadership, etc
2 Analytics, leader, role, etc
3 Telecom, leader, management, manager, etc
4 IT, leader, role, etc
5 Management, HR, Role, Leadership
I want a new pandas column that will give me the following basis the selection of the keywords from the information column. For example: if I search for HR in row 1, then the HR Skills should be returned. In row 5 if I search for HR and Management- HR Management Skills should be returned. The output should look like this :
ID SkillSet
1 HR Skills
2 Analytics Skills
3 Telecom Skills
4 IT Skills
5 HR and Management Skills
The problem is more around doing an active keyword search or multiple keyword search. How should I achieve this?
df.loc[df['INFORMATION'].str.contains('HR'), 'SkillSet'] = 'HR Skills'

Api.ai Multiple Items in Order System

I am creating a sample app in which multiple items as per categories can be chosen. Please see flow as below.
If i want to opt 3 items and all are falling in different categories. The configuration will like this.
A) Item 1
Category 1
Price1
ingrdient1
B) Item 2
Category 2
Price2
ingrdient3
C) Item 3
Category 3
Price3
ingrdient3
So to achieve this i have to create parameter1, parameter2, parameter3 and so on.
Is there any way in api.ai which supports collection concept like object[0], object[1], object[3] ....
here object[0] holds
A) Item 1
Category 1
Price1
ingrdient1
Thanks,
Dinesh
Not currently.
Api.ai are working on List entity, comment here on their forum. But currently they don't support objects or arrays being passed as parameters.
You would have set up entities and parameters for price, item, category, ingredient to be passed to your own webservice.
Try asking on their forum though, they're very open to suggestions and improvements for the platform.

How to change a attribute to a measure with DAX?

I have a lot of data in my database and I wish to display it as a Pivot Table using Power Pivot, however, some of my data is text (some flags, month names, names, last names, etc). Is there a way that I could convert these attributes to measure so the overall peformance of my Pivot table doesn't get affected?
I have some ideas but nothing clear yet, here is a sample of my table
UserID | Name | LName | City | State | QtySold
1111 Jon Smith 2 6 459394
1112 Alex Cash 6 2 31232
1113 Rob Adams 5 1 12434
I only need to use these attributes when I'm looking the data at UserID level (if I see the data at City, State leven It won't mather since I don't care about names / last names) is there a way I could evaluate the context and make the Name a measure?
Something like
=IF(UserID, DisplayLastName, BLANK())
(A new measure that checks if I'm using UserID, If I'm then display the LastName, If not, display blank)
Any ideas?
Thanks,
Oh well it seems that I found what I was looking for
LName:=IF(ISFILTERED(Details[UserID]),VALUES(Details[LName]),BLANK())
As long as UserID is on the Pivot Table, the LName measure will work.

Resources