1

I have a question for a table on Power BI. In fact, I have a first colums that is the name or the id of a process, the 2nd one, that is the number of the step of the process, and the 3rd one that is the time of the step. Example :

Column 1: [A, A, B, A, C, B, C]

Column 2: [1, 2, 1, 3, 1, 2, 2]

Column 3: [8, 9, 6, 10, 18, 7, 19]

I want it to appear as a table with the first colum the process (without duplicate), and new columns with the steps and associated hours, like :

Column 1: [A, B, C]

Column 2: [8, 6, 18] #hour of the step 1 of each process

Column 3: [9, 7, 19] #hour of the step 2 of each process

Column 4: [10, Nan, Nan] #hour of the step 3 of each process

Is this possible to do directly on Power BI or I need to pass by other tools such as python? Thank you,

Tam
  • 11
  • 1

1 Answers1

0

You can achieve this with following measures

_1 = MINX(FILTER(tbl,tbl[colB]=1),tbl[colC])

_2 = MINX(FILTER(tbl,tbl[colB]=2),tbl[colC])

_3 = MINX(FILTER(tbl,tbl[colB]=3),tbl[colC])

Solution

A power query solution would be following

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIEYgulWB0IzwiILeE8Y5C8AZjrBFVqBueBlJqDec5QOUMLOBckaQg0KBYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [colA = _t, colB = _t, colC = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"colA", type text}, {"colB", Int64.Type}, {"colC", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"colB", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"colB", type text}}, "en-US")[colB]), "colB", "colC", List.Min)
in
    #"Pivoted Column"
smpa01
  • 4,149
  • 2
  • 12
  • 23
  • Thank you for your answer. I tried the function minx but got the error of MINX (same with MIN) not recognized. I don't know if it is because I work on Power BI desktop and not Power BI (I forgot to precise it). Is there a solution by using GROUP BY for the first column (with A,B,C) and the second one with an if, for example if the column step = 1 therefore enter the value of the column hour, otherwise null? (Sorry I'm new with Power BI) – Tam Sep 30 '21 at 09:26
  • Load your tables in power bi. On the modelling tab, click on New Measures and create all the measures that are written with `MINX` – smpa01 Oct 01 '21 at 04:12