Forum Discussion

Kevboy_telford's avatar
Kevboy_telford
Frequent Visitor
8 years ago
Solved

data transformation for Sankey chart

I am trying to build a Sankey chart based on my data 

I want a user to be able to select dates using a slicer and see where the customers have gone from / to over that date range

 

my data is stored in the following way:

datescustomeridCurrent_Status
02/01/20181096082Live-1st
03/01/20181096082Live-2nd
04/01/20181096082Live-2nd
05/01/20181096082Live-2nd
06/01/20181096082Live-2nd
07/01/20181096082Live-2nd
08/01/20181096082Live-2nd
09/01/20181096082Live-2nd
10/01/20181096082Live-2nd
11/01/20181096082Live-2nd
12/01/20181096082Live-2nd
13/01/20181096082Live-2nd
14/01/20181096082Live-2nd
15/01/20181096082Live-2nd
16/01/20181096082Live-2nd
17/01/20181096082Live-2nd
18/01/20181096082Live-2nd
19/01/20181096082Live-2nd
20/01/20181096082Live-2nd
21/01/20181096082Live-2nd
22/01/20181096082Live-2nd
23/01/20181096082Live-2nd
24/01/20181096082Live-2nd
25/01/20181096082Live-Regular
26/01/20181096082Live-Regular

 

so if a user selects 2nd Jan and 25th Jan using a slicer - I want a table to show 

 

first rangesecond rangecustomerid
Live-1stLive-Regular1096082

 

The equivalent in TSQL is

SELECT Isnull(s.current_status, 'New') AS first_range, 
e.current_status AS second_range,
e.customerid
FROM
(SELECT *
FROM customer_journey
WHERE dates = '20180102'
) s
FULL OUTER JOIN
(SELECT *
FROM customer_journey
WHERE dates = '20180125'
) e
ON s.customerid = e.customerid

 

I think I need 2 tables and then link them using the customerid so I can do a measure showing the numbers but cant seem to create the tables...

 

cheers

 

Kevin

  • Kevboy_telford,

     

    The Source and Destination fields don't accept measure. You may try adding a calculated table and using measure in Visual level filters.

  • In the end I've had to create a view within the source system and build from there as I dont think Power BI can do the above that easily...

2 Replies

  • v-chuncz-msft's avatar
    v-chuncz-msft
    Community Support

    Kevboy_telford,

     

    The Source and Destination fields don't accept measure. You may try adding a calculated table and using measure in Visual level filters.

  • In the end I've had to create a view within the source system and build from there as I dont think Power BI can do the above that easily...