Forum Discussion
checking for a condition and creating a table consisting a single row
- 2 years ago
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc3dCoMwDIbhe+mxjib9sV6LeCDimCBU1LHbX5NsY1ByEgg8fO8wGIQWoEWLzjTmsZ5XPtZ52sqDtpxgxqYg1JAjFAU5DXlCnSCvoUAoCQoaioR6QVFDHSGwojpNJVYgKmmqZ4Wi+j91z8cyT+fFKUauRlt+LQetJF65hZo8950JWOSRj3FWaQG3fI2+LbBJHfrFgGOezPgG", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Name = _t, Cost = _t, Part = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type text}, {"Name", type text}, {"Cost", Int64.Type}, {"Part", type number}}), Historicals = Table.SelectRows(#"Changed Type", each ([Name] = "historical")), Forecast = Table.SelectRows(#"Changed Type", each ([Name] = "forecast")) in if Table.RowCount(Historicals) >0 then Table.LastN(Historicals,1) else Table.FirstN(Forecast,1)
Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
If you are unsure how to do that please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
If you want to get answers faster please refer to https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523
Thanks for pointing out the mistake. I am new to this forum but I updated the question and added the sample data in a table. Hope this will provide more clarity
- lbendlin2 years agoSuper User
for both scenarios you can apply these rules
- filter out all rows without values
- filter out all rows where the name is "upper" or "lower"
- keep bottom 1 row.
- animeshsingh7372 years agoFrequent Visitor
This is just a sample data. In the second case, there can be multiple dates with forecast, lower and upper. I want the first forecast for that. But in the first case, if upper, lower, and forecast are empty in a row then there will be no further rows.
- lbendlin2 years agoSuper User
Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.