Forum Discussion

acaryasin's avatar
acaryasin
Frequent Visitor
4 years ago
Solved

How to create a measure to filter data (desired column example below)

Hello everyone,

 

I have two tables below.

I explained what I need in desired column.

Is there anybody to help me a creating kind of measure?

 

Thanks in advance,

 

 

 

IDTask StatuTask NameOrderDescriptionDesired Output / Measure 
15CompletedA1Retrieve  
15WaitingB2Assestment  
15Not startedC3Review 1  
15In progressD4Initial snet  
15Not startedE5Complete 1  
15CancelledF6Review 2  
15WaitingG7AB ReviewInitial snetIf any task status is "In progress" belong a specific ID that Task Name should be writen to here in the row of AB Review,
if there is no "In progress" status in that specific ID, here should be empty. 
27Not startedA1Retrieve  
27In progressB2Assestment  
27CancelledC3Review 1  
27CompletedD4Initial snet  
27WaitingE5Complete 1  
27Not startedF6Review 2  
27CompletedG7AB ReviewAssestmentIf any task status is "In progress" belong a specific ID that Task Name should be writen to here in the row of AB Review,
if there is no "In progress" status in that specific ID, here should be empty. 
27CompletedH8Final Sent  
28Not startedA1Retrieve  
28WaitingB2Assestment  
28WaitingC3Review 1  
28WaitingD4Initial snet  
28WaitingE5Complete 1  
28WaitingF6AB Review If any task status is "In progress" belong a specific ID that Task Name should be writen to here in the row of AB Review,
if there is no "In progress" status in that specific ID, here should be empty. 
  • Why would this need to be a measure? Can the result be impacted by user interaction?

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZI9D4IwEIb/SsPsAn7AKvi5OOjgQBiIXkiTUght8O97FA0t0EaHNznI0+vdA2nq+Wtv4SVVWTOQ8MR6i/ExV5ANhRawJF62+JD3nErKC6xiTNDxQoCQJXBpkpdKEiHzpu+aYJaqa0vhRXyTPXNSN1XRgBD4tMOs1Fu8K2dEcHD23mP0Lcbdk5w/gDHFHjCbYY7Att0RE3bbxaRHx/N0Z4JwMovVnmLNPR0GFa3PbfXXk9r3c9pT9LClw9zMblZ3kxnm7Glbzp45YaLuFspx6pthI/rDc/TrXzoi7YZNzu3XZF1+TfLrVjeGYPYG", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Task Statu" = _t, #"Task Name" = _t, Order = _t, Description = _t, #"Desired Output / Measure" = _t]),
        #"Added Custom" = Table.AddColumn(Source, "Output",(k) => if k[Description] = "AB Review" then try (Table.SelectRows(Source,each [Task Statu]="In progress" and [ID]=k[ID])){0}[Description] otherwise null
    else null
    )
    in
        #"Added Custom"

    How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

     

1 Reply

  • Why would this need to be a measure? Can the result be impacted by user interaction?

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZI9D4IwEIb/SsPsAn7AKvi5OOjgQBiIXkiTUght8O97FA0t0EaHNznI0+vdA2nq+Wtv4SVVWTOQ8MR6i/ExV5ANhRawJF62+JD3nErKC6xiTNDxQoCQJXBpkpdKEiHzpu+aYJaqa0vhRXyTPXNSN1XRgBD4tMOs1Fu8K2dEcHD23mP0Lcbdk5w/gDHFHjCbYY7Att0RE3bbxaRHx/N0Z4JwMovVnmLNPR0GFa3PbfXXk9r3c9pT9LClw9zMblZ3kxnm7Glbzp45YaLuFspx6pthI/rDc/TrXzoi7YZNzu3XZF1+TfLrVjeGYPYG", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Task Statu" = _t, #"Task Name" = _t, Order = _t, Description = _t, #"Desired Output / Measure" = _t]),
        #"Added Custom" = Table.AddColumn(Source, "Output",(k) => if k[Description] = "AB Review" then try (Table.SelectRows(Source,each [Task Statu]="In progress" and [ID]=k[ID])){0}[Description] otherwise null
    else null
    )
    in
        #"Added Custom"

    How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".