Forum Discussion
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:
| dates | customerid | Current_Status |
| 02/01/2018 | 1096082 | Live-1st |
| 03/01/2018 | 1096082 | Live-2nd |
| 04/01/2018 | 1096082 | Live-2nd |
| 05/01/2018 | 1096082 | Live-2nd |
| 06/01/2018 | 1096082 | Live-2nd |
| 07/01/2018 | 1096082 | Live-2nd |
| 08/01/2018 | 1096082 | Live-2nd |
| 09/01/2018 | 1096082 | Live-2nd |
| 10/01/2018 | 1096082 | Live-2nd |
| 11/01/2018 | 1096082 | Live-2nd |
| 12/01/2018 | 1096082 | Live-2nd |
| 13/01/2018 | 1096082 | Live-2nd |
| 14/01/2018 | 1096082 | Live-2nd |
| 15/01/2018 | 1096082 | Live-2nd |
| 16/01/2018 | 1096082 | Live-2nd |
| 17/01/2018 | 1096082 | Live-2nd |
| 18/01/2018 | 1096082 | Live-2nd |
| 19/01/2018 | 1096082 | Live-2nd |
| 20/01/2018 | 1096082 | Live-2nd |
| 21/01/2018 | 1096082 | Live-2nd |
| 22/01/2018 | 1096082 | Live-2nd |
| 23/01/2018 | 1096082 | Live-2nd |
| 24/01/2018 | 1096082 | Live-2nd |
| 25/01/2018 | 1096082 | Live-Regular |
| 26/01/2018 | 1096082 | Live-Regular |
so if a user selects 2nd Jan and 25th Jan using a slicer - I want a table to show
| first range | second range | customerid |
| Live-1st | Live-Regular | 1096082 |
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
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-msftCommunity Support
The Source and Destination fields don't accept measure. You may try adding a calculated table and using measure in Visual level filters.
- Kevboy_telfordFrequent Visitor
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...