Thursday, April 11, 2019

Israeli Election 2019 - תמיכה בכחול לבן והליכוד מול מעמד חברתי - כלכלי

 רציתי להשוות את דפוסי ההצבעה למפלגת כחול לבן מול הליכוד בראי המדד החברתי-כלכלי בארץ
השתמשתי בפתרון אורקל בענן, הקיים גם כגרסת דסקטופ

נגלה כבר עכשיו את התוצאה המרכזית של גרף אחוז תמיכה מול דירוג כלכלי חברתי, כאשר גודל הבועה הוא מספר הקולות הכשרים. גרף עליון הוא ליכוד ותחתון כחול-לבן



ועכשיו מתחיל מהתחלה
 

ניתן להוריד את קובץ תוצאות הבחירות על פי ישובים ועל פי קלפיות מאתר ועדת הבחירות המרכזית. לצערי הוא לא מאד קריא באקסל ועל כן נאלצתי להריץ אותו בכלי המרת ג'יבריש, השתמשתי בזה
למרות שהוא עדיין לא קריא באקסל, הוא נראה מצויין בכלי הויזואליזציה של אורקל




מה שעניין אותי היה להסתפק באחוז התמיכה בכחול לבן מול אחוז התמיכה בליכוד בכל ישוב ולהשוות אותם לנתונים הסוציו-אקונומיים שיש לי בקובץ נתוני הלשכה המרכזית לסטטיסטיקה לשנת 2015. על כן אפעיל תהליך זרימה המסתיר את מרבית נתוני המפלגות וממיר את נתוני שתי המלגות הרלוונטיות לאחוז מכלל המצביעים החוקיים

לפני זה בדקתי את ההתאמה בין שמות הישובים בשתי הרשימות. כך גיליתי לצערי שקיימת רשימה ארוכה של ישובים קטנים שאינם קיימים במאגר הדרוג החברתי כלכלי. לצערי התוצאות לא יתייחסו לאותם יישובים קטנים


 בשלב זה יצרתי את הפרויקט החדש. הוספתי חישוב של אחוז כחול לבן ואחוז הליכוד מכלל הקולות הכשרים והוספתי קו מגמה לינארי. הקו נראה מתאים לכחול לבן (גרף תחתון), ונראה בברור שככל שהמדד החברתי כלכלי עולה, כך יש נטיה להצביע כחול לבן. לעומת זאת דפוסי הצבעה לליכוד אינם מתאימים באמת למגמה לינארית (גרף עליון) ננסה קו מגמה אחר

החלפתי בשני המקרים לקו מגמה פולינומיאלי (מדרגה 3), זה נראה הרבה יותר מתאים


שני דברים הטרידו אותי 

לגבי הליכוד, נראה שיש לו בעיה עם ישובים בתחתית הדירוג החברתי כלכלי, הליכודבשיאו באחוזונים 30-50 ומתדרדר משם. מה הם הישובים הללו בצד השמאלי של הגרף ומה הם בוחרים? הגדרתי את גרף הליכוד כפילטר והוספתי גרף נתוני המפלגות שעברו את אחוז החסימה

מסתבר שהסיבה לחולשה יחסית של הליכוד בשני העשירונים הנמוכים במדד הכלכלי חברתי, זו העדפה שלהם לבחור בשס ויהדות התורה

שאלה נוספת הייתה מי הישובים המסתתרים בתחתית הגרף של כחול לבן ופוגעים באחידות המגמה של תמיכה בכחול לבן עולה עם העליה במעמד הכלכלי חברתי? נוסיף לגרף את שם המחוז. עכשיו בכל ברור, בחלק מישובי יהודה ושומרון אין אהדה גדולה לכחול לבן, ללא קשר למעמד חברתי כלכלי (אלפי מנשה, הר אדר ואורנית, הולכים לפי דפוס הארצי, למרות השיוך המחוזי), זה מסביר את החריגה


 


Thursday, March 14, 2019

Simple integration of Data Visualization in OBI Dashboard

In OBIEE 12.2.1.4 and OAC (Oracle Analytic Cloud) we can easily integrate Data Visualization projects with Dashboard Prompt capabilities. That works both with Subject Areas and Data Visualization Data Sources.

PLEASE NOTE: At the moment the DV Project should not contain any active filter at the filter level (top part of the screen). If it does, the prompt doesn't work.



Lets do 2 examples. Subject Area based and Data Source Based.

Example 1:

Lets create a simple Data Visualization based on Subject Area:


In a dashboard I can add the project as any other OBI component:

Please note you can set size of the project within the Dashboard and select the Canvas you need, assuming you have more than one (Show View).


Next I can create a regular Dashboard Prompt. Please note we don't have to do anything. As long as the prompt based on the same Subject area as the Project it would work. In my case I created the Prompt "Offices"."D2 Department" column. Note the "Offices" don't participate in the Project.

Last thing I do is to place both on the same Dashboard page, and it just works:


Changing the selection in the Prompt, changes the filter in the Project and we can see different values in our data (and other expected changes, such as graph scales change):




Example 2

We can do the same with Data Set based Projects:

I'll use the Sample Project.


When creating the Dashboard Prompt I can see the Data Set data sources and not only Subject Areas, so I will use it:






Again, we can use both in a Dashboard, and it just works, with no additional effort.









Tuesday, October 2, 2018

Oracle Data Visualization and the Attribute function

The Attribute function is an important function of Oracle Data Visualization, useful when we attempt to create something interesting based on measure values. It was covered by Philippe Lions in the post "Leverage the 'Attribute' Function to Boost Data Insights", but I want to dig a bit deeper and show a simple use case.

First example why we need it:

 I want to create 2 groups one with profit over 500 and the other with 500 and bellow. So I create the following calculation :






In our case I used City and few measures (Row Count and Profit), as a result I have each city assigned to group:




In many cases I jut want the totals, for each group. So I'll remove the city and get a strange result:



What happened?  Our 'Case 1' is treated as a measure and aggregated!

In Answers we had an option to mark "Treat as an attribute column":
but in Answers we have many layers, this part is in criteria, and we don't really have it in data visualization that uses more direct and simple approach.  

The Attribute function should solve this problem.  

The explicit syntax for this function is:  
ATTRIBUTE(<expression> BY <attribute list> WHERE <predicate>)  

The BY clause may be empty, in which case grand total grain is assumed.


I will return to our example. Instead of case when Profit>500 then 'Group A' else 'Group B' end
I will use case when Attribute(Profit by City)>500 then 'Group A' else 'Group B' end
And replace the Case 1 with Case 2:

Great.


Lets talk a bit about the BY part:

The Profit or any other measure is summarized according to the BY clause. In  our case we wanted to summarize it by City. If we want it on any other level we should define it.

For example in my data the primary key of the data is Order ID and Order Line ID. We can use them in the BY clause:
In this case the profit is summarized by the lowest level of the data grain and return different results:

But this is exactly the case when we can omit the BY clause and get exactly the same result:











The wrong way to use Attribute function:

From what I have seen, the attribute function should be used as close to the measure as possible. For some reason, people (me including) tend to do it the other way, which seems to be the wrong way.

In our example using Attribute function outside the Case function:





Will get you an error with some advise

this can be resolved by having an administrator refresh the server metadata.
SQL Issued: SET VARIABLE ENABLE_DIMENSIONALITY = 1;


You don't have to, just keep the Attribute function close to the measure as described above.




If, for some reason, you insist on this approach, the workaround is to use numeric values as result.




Or you can always use some cast function on top of it.





It will work:

Did I mention it's an ugly and not recommended approach?






Monday, July 23, 2018

Adding Your own cities to Oracle DV - for the clueless

The aim of this post is to add your own cities to the Oracle geo-Json files in Oracle Data Visualization (DV). There are lots of smart options to create the geo files, that were already covered (extracting from Oracle database map, converting from maps Shapefile, based on image ...) this post describes how clueless person can do it with Excel.
This post is relevant for most types of Oracle Data Visualization (including desktop, OAC - cloud, on-prem). It was "quick and dirty" work and naturally can be greatly improved.

Introduction


There are 3 layer when you work with maps and DV.
  1. The background map (such as Google Maps, Oracle Maps...) 
  2. Your Data that contains information such as country or city names.
  3. A layer that translates your data to geographical info such as specific location (lat&long point) or borders (a set of lat&long points). This layer is created in Oracle DV using geo-Json files.
We can see the existing maps/geo-json files in the Console:



You can see them as physical files as well. The DV desktop files are located in: C:\Users\YOUR_USER_NAME\AppData\Local\Temp\DVDesktop\config\fmwconfig\biconfig\catalogs\basemaps   (replace YOUR_USER_NAME with your windows user name)

In the file world_cities.json, a single city in this file looks like this: {"type":"Feature","_id":"293394","geometry":{"type":"Point","coordinates":[34.76807,32.08194]},"properties":{"City Name":"Tel Aviv-Yafo","ISO":"ISR","Country Name":"Israel","State Name":"Tel Aviv","Scalerank":"2","Country Code_State Province Name_City Name":"ISR_Tel Aviv_Tel Aviv-Yafo","Country Name_State Province Name_City Name":"Israel_Tel Aviv_Tel Aviv-Yafo","Country Name_City Name":"Israel_Tel Aviv-Yafo","Country Code_City Name":"ISR_Tel Aviv-Yafo"}},

In this case we translate the City Name (Tel Aviv-Yafo) to coordinates :[34.76807,32.08194]

The system finds your data and scans existing map files for it, then translates it to geo-location. As a result you can have the same point with multiple name(Tel Aviv-Yafo, Tel Aviv, Tel Aviv Yafo, TA-Israel....) including translation to your local languages...The system would work fine! The one thing that is best not to do is to have 2 rows with the same City Name.

So I wanted to take the existing world_cities.json and add all the locations in Israel, in English, Hebrew and Arabic. The original file has few cities in English names.

How do I find possible location? Google it! There are plenty of people that published free relevant data to your country, or you can right click a map such as google map and copy manually the location coordinates or get it from the URL (for example https://www.google.com/maps/@32.08194,34.76807,17z), just note in google the order is [lat, long] in our geo-json file it's [long,lat].
It's always a good idea to check first at Oracle Analytics store - Maps & Spatial. Maybe someone already did the hard work.



Solution

To make thing extra easy I created an Excel file with a set of calculations. All I care about is filling the first 6 columns: running number, City Name, State Name, Country Code, country name and Long,Lat. the result is column G that is result you want to add to world_cities.json. 
The excel file is located here.
Just delete the values in columns B, C, D, E, F
Copy line 2 (columns A - AG) to the bellow lines
Add your own data as described above:
B - City Name
C - State Name
D - Country Code
E - Country Name
F - Long,Lat


Copy column G result and Paste it as Values.
Add the Values to world_cities.json, before the last line (our data has a comma at the end of the line, it can't be the last data line).

Here is am example file world_cities-HEB.json with 76 major cities in Israel added in English, Hebrew and Arabic.
Here is an example of world_cities_Hebrew_All_Israel.json with over 1000 places in Israel added, only in Hebrew.

Of course if you don't need all the wold cities and need only the local cities for your case you can create your own smaller json file without the world cities, based on world_cities.json file structure (in that case you can greatly simplify the attributes list, if you want).

Last step is to upload the files as custom map layers.

For the DV Desktop or OAC (Oracle Analytic Cloud) we can upload the file using the Console:

Press "Add Custom Layer (click, or drag and drop GeoJSON file)"
Select the json file.
You are required to select Layer Keys. Select the "City Name" at least:


Now you can use this in your maps:

Most likely the layer would be selected automatically. You can manually select your preferred layer option in properties any way.



You can find the same in OAC. Check the Console for Maps or use the URL similar to:
http://SEVER:PORT/dv/ui?consoletab=manageMapDataTab