简体   繁体   中英

Conditional transformation data in Power BI

The question about transformation data in Power BI.

I have a text file with spaces as separators. Some rows (where day in date less than 10) contain double space before one field. It is always the third field.

Tue May  4 13:57:50 BST 2021: 64 bytes from 8.8.8.8: icmp_seq=12 ttl=119 time=9.22 ms
Tue May  4 13:58:05 BST 2021: 64 bytes from 8.8.8.8: icmp_seq=13 ttl=119 time=10.2 ms
Tue May  4 13:58:20 BST 2021: 64 bytes from 8.8.8.8: icmp_seq=14 ttl=119 time=8.77 ms
Tue May  4 13:58:35 BST 2021: 64 bytes from 8.8.8.8: icmp_seq=15 ttl=119 time=9.69 ms
Tue May  4 13:58:50 BST 2021: 64 bytes from 8.8.8.8: icmp_seq=16 ttl=119 time=9.22 ms

So I split this file by spaces and some rows are split for 15 columns and some for 16. I do a lot of transformations with this file then so I need to be able to make the conditional transformation. I didn't find any solutions by myself, so I'll be appreciated for advice.

I found a few solutions.

Shortly, The first one is using a standard function Split Column which could be used in few steps.

  1. Split by positions the first 3 fields
  2. Clear it from spaces
  3. Split by space the rest

The second way to do something similar is using Python. To successfully insert step with Python script in your current transformation you should:

  1. Go to Transform data -> Advanced editor and copy current steps, because after insertion Python step we should do a Navigation step, which replaces all existing steps.
  2. Find a step where you want to insert a new Python transformation and click on Transform -> Run Python script.
  3. Then write code and save the result
  4. Then click on dataset name and agreed with replacing all steps
  5. Now copy your previous steps and past them back in Advanced editor

I described the solutions here https://koftaylov.blogspot.com/2021/05/another-day-building-power-bi-dashboard.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM