728x90
https://channel.io/ko/blog/nps_basic
index="log_test_com" uri_path IN (/test/nps)
| stats count by _time, uuid, point
| sort - _time `comment("최신 응답이 최상단")`
| streamstats count as response_number by uuid `comment("동일 유저의 여러 개 응답에 넘버링")`
| where response_number=1 `comment("최신 응답만 필터링")`
| eval nps_category=case(point>=9 AND point<=10, "promoter", point>=7 AND point<=8, "passive", point>=0 AND point<=6, "detractor") `comment("점수 범위에 따라 라벨링")`
| stats count as category_count by nps_category `comment("각 라벨 개수 구하기")`
| eventstats sum(category_count) as total_responses `comment("total_responses 컬럼 만들어서 category_count의 총합으로 채우기")`
| eval percentage = round((category_count/total_responses)*100, 2)
| where nps_category="promoter" OR nps_category="detractor"
| stats sum(percentage) as nps by nps_category
| eval nps = case(nps_category="promoter", nps, nps_category="detractor", -nps)
| stats sum(nps) as Net_Promoter_Score
728x90