Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hello everyone,
we all love sankey charts. I want to draw a simpel sankey. It turns out the data prep isnt that simple after all. Can you help?
The incoming data looks like this:
| Channel | Website | Conversion | Sales |
| ProductSite_A | Download | 5000 | |
| ProductSite_A | Contact | 15000 | |
| ProductSite_B | Subscription | 1000 | |
| ProductSite_B | Contact | 500 | |
| ProductSite_A | Contact | 3000 | |
| ProductSite_B | Download | 6000 | |
| ProductSite_B | Subscription | 9000 | |
| ProductSite_B | Contact | 700 | |
| ProductSite_C | Download | 1400 |
I know I have to transform the data in a way, that I get a column for source and one for target (one extra for the occurcances) and after all the value of sales needs to be calculated for this as well. Does anyone have a clou? I am freaking out on this.
The final table should look a little like this.
| Source | Target | Occurs | Sales |
| ProductSite_A | 2 | ? | |
| ProductSite_B | 2 | ? | |
| ProductSite_A | 1 | ? | |
| ProductSite_B | 3 | ? | |
| ProductSite_C | 1 | ? | |
| ProductSite_A | Download | 1 | ? |
| ProductSite_A | Contact | 2 | ? |
| ProductSite_B | Subscription | 2 | ? |
| ProductSite_B | Contact | 2 | ? |
| ProductSite_B | Download | 1 | ? |
| ProductSite_C | Download | 1 | ? |
Solved! Go to Solution.
Hi @raymond,
You could create a calculated table with below formula:
Table =
UNION (
SUMMARIZE (
SELECTCOLUMNS ( Data, "Source", Data[Channel], "Target", Data[Website] ),
[Source],
[Target],
"Occurs", COUNT ( Data[Sales] ),
"Sales", SUM ( Data[Sales] )
),
SUMMARIZE (
SELECTCOLUMNS ( Data, "Source", Data[Website], "Target", Data[Conversion] ),
[Source],
[Target],
"Occurs", COUNT ( Data[Sales] ),
"Sales", SUM ( Data[Sales] )
)
)
Best regards,
Yuliana Gu
Hi @raymond,
You could create a calculated table with below formula:
Table =
UNION (
SUMMARIZE (
SELECTCOLUMNS ( Data, "Source", Data[Channel], "Target", Data[Website] ),
[Source],
[Target],
"Occurs", COUNT ( Data[Sales] ),
"Sales", SUM ( Data[Sales] )
),
SUMMARIZE (
SELECTCOLUMNS ( Data, "Source", Data[Website], "Target", Data[Conversion] ),
[Source],
[Target],
"Occurs", COUNT ( Data[Sales] ),
"Sales", SUM ( Data[Sales] )
)
)
Best regards,
Yuliana Gu
Hi @v-yulgu-msft that works pretty good I have to say. The Sum of Sales needs to be divided by 2 though otherwise you would double the amount of sales.
Another question: is there a way to do this in power query as well. I was thinking it might cause some performance issues if I am using a calculated table. Is my concern ligitimate?
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 50 | |
| 44 | |
| 42 | |
| 19 | |
| 19 |
| User | Count |
|---|---|
| 69 | |
| 68 | |
| 33 | |
| 32 | |
| 32 |