Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I would like to pivot the data to have below output (One ID with different date fields).
How to do this? here
Sample data here.
ID | created | Order Status - Closed | Order - Dispatched | Field Status - Accepted | Field Status - Closed | ............. |
ID-01275049 | 12/31/2019 4:01:04 PM | 2/18/2020 2:59:44 PM | xxxxx | |||
ID-01275052 | 12/31/2019 4:01:11 PM | 12/31/2019 4:03:28 PM | 12/31/2019 4:11:36 PM | 12/31/2019 4:12:00 PM | xxxxx | |
ID-01275106 | 12/31/2019 4:08:23 PM | 12/31/2019 4:08:52 PM | 1/8/2020 4:53:52 PM | 1/8/2020 8:05:03 PM | xxxx | |
ID-01275069 | 12/31/2019 4:02:58 PM | 12/31/2019 4:42:08 PM | xxxxx |
Solved! Go to Solution.
Hi, @PBI_newuser
I modified the measure and column to make the result correct. In my original logic, each value will be repeated twice, so your result will be doubled.
I found that 'created' value doesn't appear after January 2020, so my results actually only have valid values for two months.
The mmmyy column I made is only used to format the date of the line chart, and cannot be used for filtering, because your table data is too large to pvoit and it will filter different value values.
Column1 =
VAR a = data[ID]
VAR b =
MAXX (
FILTER ( data, [ID] = a && [History New Value] = "created" ),
[History CreatedDate]
)
VAR c =
MAXX (
FILTER ( data, [ID] = a && [History New Value] = "Field Status - Accepted" ),
[History CreatedDate]
)
RETURN
IF(b<>BLANK()&&c<>BLANK(),
DIVIDE ( DATEDIFF ( b, c, SECOND ), 3600 )
)
Measure1 =
VAR a =
CALCULATE ( COUNT ( data[Column1] ), FILTER ( data, [Column1] <> BLANK ()&&[History New Value]="created" ) )
var b=
CALCULATE ( SUM( data[Column1] ), FILTER ( data, [Column1] <> BLANK ()&&[History New Value]="created" ) )
RETURN
DIVIDE ( b, a * 2 )
Here is my sample .pbix file. Hope you can understand what I said.
If it doesn’t solve your problem, please feel free to ask me.
Best Regards
Janey Guo
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @PBI_newuser
You can use 'pivot column' function in PQ.
Like this:
Best Regards
Janey Guo
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-janeyg-msft , i tried the solution you proposed, but maybe data is too large, so it takes long time to load and ended up i got the below error message.
DataSource.Error: The operation has timed out
Is there any other way (e.g. DAX column) to create the date columns?
Hi, @PBI_newuser
If you data is large, using pq will time out, then using dax is estimated to be similar, you can use a matrix visual to show the pviot table.
Like this:
If it doesn’t solve your problem, please feel free to ask me.
Best Regards
Janey Guo
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-janeyg-msft , thanks! It works.
But, I need more columns to show beside the date columns.
How can I create columns to show the Hours difference between
1) [created] and [Order Status-Dispatched],
2) [Field Status - For Dispatch] and [Order - Dispatched], etc.?
Hi @v-janeyg-msft ,
I wanna calculate the hours difference between the columns first and display as the screenshot, then plot a chart with the average of the hours difference by month. Is it possible?
Hi, @PBI_newuser
I create some measures and columns to display your desired result.
Like this:
Column1 =
VAR a = data[ID]
VAR b =
MAXX (
FILTER ( data, [ID] = a && [History New Value] = "created" ),
[History CreatedDate]
)
VAR c =
MAXX (
FILTER ( data, [ID] = a && [History New Value] = "Field Status - Accepted" ),
[History CreatedDate]
)
RETURN
DIVIDE ( DATEDIFF ( b, c, SECOND ), 3600 )
Measure1 =
VAR a =
CALCULATE ( COUNT ( data[Column1] ), FILTER ( data, [Column1] <> BLANK () ) )
RETURN
DIVIDE ( SUM ( data[Column1] ), a * 2 )
Here is my sample .pbix file.Hope it helps.
If it doesn’t solve your problem, please feel free to ask me.
Best Regards
Janey Guo
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-janeyg-msft , thank you so much for your help!
Thank you!
Hi, @PBI_newuser
I modified the measure and column to make the result correct. In my original logic, each value will be repeated twice, so your result will be doubled.
I found that 'created' value doesn't appear after January 2020, so my results actually only have valid values for two months.
The mmmyy column I made is only used to format the date of the line chart, and cannot be used for filtering, because your table data is too large to pvoit and it will filter different value values.
Column1 =
VAR a = data[ID]
VAR b =
MAXX (
FILTER ( data, [ID] = a && [History New Value] = "created" ),
[History CreatedDate]
)
VAR c =
MAXX (
FILTER ( data, [ID] = a && [History New Value] = "Field Status - Accepted" ),
[History CreatedDate]
)
RETURN
IF(b<>BLANK()&&c<>BLANK(),
DIVIDE ( DATEDIFF ( b, c, SECOND ), 3600 )
)
Measure1 =
VAR a =
CALCULATE ( COUNT ( data[Column1] ), FILTER ( data, [Column1] <> BLANK ()&&[History New Value]="created" ) )
var b=
CALCULATE ( SUM( data[Column1] ), FILTER ( data, [Column1] <> BLANK ()&&[History New Value]="created" ) )
RETURN
DIVIDE ( b, a * 2 )
Here is my sample .pbix file. Hope you can understand what I said.
If it doesn’t solve your problem, please feel free to ask me.
Best Regards
Janey Guo
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-janeyg-msft , I got what you meant but each value doesn't repeat twice but some more than twice. I have created 2 new pages with new dataset (only Oct-20 data) here. I downloaded the data from "Sample1" page, and noticed same ID has repeated more than twice.
The "Sample2" page should got the below result (in "Datachecking" file) but I am not sure how to calculate it by using the measures.
Thanks!
Hi, @PBI_newuser
There is no duplication in the matrix, because there are row and column restrictions in the matrix. I have restricted all measures and columns, and will not calculate values that should not be calculated. Can you understand? If you want to display in the table, you need to filter in filterpane
Please carefully look at the measure and column I wrote, and understand the context in each visual!
Best Regards
Janey Guo
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-janeyg-msft , thank you so much for the time and effort you put toward helping me find the right solution for my report! Truly appreciate it! 😊
Hi, @PBI_newuser
If you can understand the role of these formulas in visuals, I will be happy. This is not the best practice, because your data volume is too large to be transposed, so the logic considered will be different. And I will be happier if you can give me some kudos.😊
Best Regards
Janey Guo
Hi @v-janeyg-msft , yes, my data volume is too large, even refresh a table takes few hours to complete. I need more time to understand the formulas as I am still new to Power BI. Sure I can give you some kudos as you are very supportive! Your detailed explanation helps me a lot! Thanks again! 😀
@PBI_newuser , select the other column then id and unpivot in power query
https://radacad.com/pivot-and-unpivot-with-power-bi
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |