Data Visualization with Power BI
Objective
As a part of DE, ML studying, this repository will contains the review of Data visualizaion Data Analysis is a fundamental process for Data Engineering and Machine Learning. However, It is important in the business field to make a best decision for profit. Power BI is a tool for making large or complex data more accessible, understandable and usable.
Before we go through Power BI, We need to remind :
- What is Power BI for
- Why Power BI is necessary
- How can we utilize Power BI for business
Section 2 Data Cleaning
Data Cleaning && Data Type
Power BI Desktop : transform , model, visualize , analyze Bower BI cloud : share & collaborate Bower BI Moile : PBI on mobie
- get data
- Transfrom Data : clean data ( power query editor)
2-12
3 views + power query editor report view (visualizae) data view : exel form model view : create relationships
2-14
GOAL : visualize the sales 카테고리, 프로모션, oevertiem sales, 배달 시간 등
TODO : 1) transform data 2) data model 3) visualize data 2-15
Basic cleaning Power Query Editor : 필요없는 top rows 제거
2-16 pbix파일 받았는데 경고 뜰 경우 Transform data : data source setting change
2-17 : 데이터 전처리 빈 row / NA 제거 : filter 이용 Duplication 제거 : remove rows 이용 (colum 클릭 --> remove duplicates)
2-18 : 데이터 타입
데이터 타입에 따라 reportview에서 생성할 수 있는 chart의 data가 달라짐
Power Query Editor 에서도 가능하고 그냥 PBI 에서도 가능함
String : count 만 가능
Date : 날짜로 변환 Locale : 각 국가형식에 맞는 data type (date, currency etc) 로 변경해줌 Fixed Decimal : currency 에 적합
2-19 : 데이터 교체 Replacing value
method 1) replace values option 사용
method 2) Error occured
method 2-1)
text-->decimal 할때 에러 뜨는 경우 있음
이때 text ==> replace values (NA ==> 0 혹은 빈칸) ==> fixed decimal
method 2-2) replace error
==> 요약 : Replace Values + Change Date를 잘 조합해서 에러를 없애고 적당한 데이터 타입을 지정하는게 중요하다
Section 3 Data Structure , Modeling
22 Data Extract
Transform Tab : Extract options
First / Last Characters
Text Before / After / Betwee Delemiter
(단위제거 값 빈칸 넣어주면 단위 상관없이 제거됨)
23 Split Column 열 분할 열분할 + character transfrom
24 Text Operation
우클릭 Transfrom - trim : 앞뒤 공백 삭제 clean : control cracters(공백, tab) 이런거 깔끔하게 삭제 capitalize : 단어 맨 앞글자 Capitalize
26 Relations
model view 에서 product_id drag and drop
은근 관계을때 생각 좀 해야함
31 piechart
==> 웬만하면 안쓰는게 낫다,, column chart better
hard to read --> column chart
- Don't use for similar values
- Don't compare 2 pie chart
- Only display percentage of total
- Ideally 2,3 categories ( max 5)
- No legend --> label + percent
32 piechart
Section 4
36 Data & Hierarchy 날짜별 데이터 년도/ 월별/ 분기별 / 일별 --> heirarchy 차트로 만들때 이것들이 중요한 부분이 될 수 있다
-
전처리 header 지정 필요 없는 row 지우기 열 분할 텍스트 단위 없애거나 나누거나,,,
데이터 타입 지정 수치 : standard
legend : 범례
Section 5 Data Model Relation
이런식의 테이블이 있다고 치면 이걸 항목 / 값 이런식으로 바꿈 ex) cost type / cost amount building cost 1000 land cost 2000 other cost 3000 building cost 1500 land cost 2500 other cost 3000
이게 피봇팅 반대는 unpivoting : transform (unpivot )
49 many to many relationship
cross filter direction : 화살표 A-->B foreign table
many to many : 양방향 중요 : 기본적으로 트랜잭션이 있는 테이블(fact table) --> demension table
50 visual filter options slicer 로 모델뷰에서 테이블에 대한 필터를 설정 할 수 있음 여러개 slicer 만들어서 필터 항목별 날짜별 값범위 이렇게 세세하게 나눌 수 있음 신기한건 하나 움직이면 reportview 의 모든 개체(visualization)모델들이 동적으로 움직이는것을 확인 할 수 있다
51 page edit 이 report view 안에서 model 들을 어떻게 배치하는지 배경을 어떤색으로 넣는지도 중요한 요소임 익건 보고용 이니까 ㅇㅇ
Section 6 Interactional Visualization I
1)이제까지는 데이터를 편집해서 가공하고 2) 가공된 데이터로 모델을 만들었다
이제부터는 이 준비된 데이터와 모델을 통해서 대화형을 visualization
54 Top N filter show top , bottom by each fields
55 Sync slicer slicer을 다른 페이지에서도 sync 해서 사용 page A 에서 설정한 슬라이서도 page B에서 똑같이 동작 method 1) page A에서 Ctrl C V method 2) view tab==> sync slicer
56 Treemap 항목이 너무 많을때 한번에 다 못보여줌 (bar chart)--> treemap space efficient! hierarchical data 에도 굿 --> 같이 grouping 해도 좋고 // detail에 sub data넣으면 색은 유지, 공간만 나눠짐
57 interaction edit 50 처럼 하나 클릭하면 다른 visual들도 그에 맞게 움직이는 것을 interaction 이라고 하는데 이것도 editable
- visual 선택 2. format tab 3. edit interations
58 drill through visual에서 해당항목을 상세히 보고싶을때 링크시켜줌
59 drill through -keep filter drill through original filter 유지할지 말지
62 activate, deactivated load PQE ( power query editor) 테이블 enalble load -- 활성화 비활성화 --> 파일크기 감소
63 reference and duplication of table refernce table duplication table
64 column from examples reference 로 table 참조 column from example로 열참조 ===> custom 해서 value 값 바꿈
Section 7 Interactional Visualization II
67 conditional column add 66을 위해 CONDITIONAL CULUMN을 만듦 요일 : 우리는 월-일 순으로 알고있지만 컴퓨터는 string type으로 아니까 abc 순으로 정렬하게 됨 이때문에 Monday-->1 Tuesday-->2 이렇게 바꿔서 새로운 column 을 만들어 줘야하는데 이때 conditional column을 씀
68 Maps filled map이랑 map이랑 다름 filled map은 해당 지역을 색칠해서 보여줌 map : bubble로 보여줌, bubble size 값에따라 크기 조절 가능
70 forecast 앞선값에 따라 예측값을 보여줄 수 있다 -> line chart ignore last : 마지막 n 값을 무시하고 예측값을 보여줌 ==> 실제 값과 비교해서 얼마나 예측이 정확한 지 볼 수 있다
정확도 : 얼마나 데이터가 누적되었는지에 따라 다르다 회색부분 : confident interval 신뢰구간
Section 8 Parameters, Functions
list query :
- table
- single value
- list
테이블에서 column 추출 ==> list로 새로운 변수? 저장공간 생성
86 bring data from web bring variable value from web page as table --> change to value --> use value on the other tables.
86 bring data from web
Section 10 : DAX( DATA ANALYSIS EXRESSION)
91 Calculated Column Calcumated Column : 말그대로 dax를 이용해서 생성된 column , 기존 column 에서 추출 / 편집한 값
92 Measure Measure : data table에는 생성되지 않고 이론적으로만 편집된 값이 존재함 따라서 data table 확인해보면 없음
- datble independent : 하나의 table에서 독립적임
- aggreate a mesure --> sum, average 등 집계함수 사용
- measure 을 사용해야만 값이 계산됨 : 그전까지는 공간 사용 X
Difference of measure and calculated column
93 measure Table Measure Table 생성 해서 Measure 만든것만 모아둔 table을 만들 수 있다 measure --> measure tool 탭 클릭 -->
94 Count, DistinctCount, CountRows Count : 중복값 포함 몇개인지 알려줌 distinct count: distinct값 몇개인지 count rows : 공백값포함, 중복값 포함 몇개인지 알려줌
95 sumx
iterative 함수들 step 1) evalutate expression for everyrows step 2) aggregate
96 average, round
97 related
DAX 함수에서 다른 테이블의 column가져오기 : related
ex) losgistics cost = sumx('sales', 'sales'[sales]*RELATED(product[volume]*0.001)
98 calculate 정적인 filter을 계산함 시각 모델로 filter링을 해도 변하지 않는 filter를 할때 유용 다른 필터링 (filter context)보다 cacluate 함수가 우선함
99 filter measure 은 다른 mesure에서 참조가 가능함 mesure1 = mesure2*0.02
100 filter
not ==> <> measrue = 조건 1 + 조건 2 filter 사용
#조건 1 , filter() #조건2,(filter)
mesure = caculate(cost *0.1 , filter(state = 'california')) + cacluate(cost*profit*0.25, filter(state<>'calinfornia'))
101 logic && and || or
102 Command fomatting cacluation : shift +enter : 줄바꿈 // ==> COMMAND
106 ALL all : filter 무시
108 ALLEXCEPT allexcept : 1개 빼고 filter 무시
109 ALLSELECTED allselected : 외부 필터는 적용 내부 필터는 무시
109 DATEADD Time intelligence :
dateadd 지정된 날짜 만큼 앞의 날짜를 포함하는 열 1달전, 1주전.. 등
110 datesYTD Dates year to day 연말을 기준으로 새로 축적 1월1일 혹은 새로운 년도가 되면 축적이 0에서 다시 시작함 datesYTD, DATSQTD, DATESMTD도 있음
111 Rounding round 1 소숫점 1자리 -1 10의 자리 round up : 반올림 / rounddown : 반내림
mround : 배수로 올림 (0.25단위라던지..)
ceiling : 올림 floor : 내림
112 format 날짜 custom format