March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Case 1 table -
Date | Name | Cost | Part |
21-11-2023 | historical | 20 | 5 |
22-11-2023 | historical | 30 | 6 |
23-11-2023 | historical | 40 | 7 |
24-11-2023 | historical | 50 | 8 |
25-11-2023 | historical | 60 | 9 |
26-11-2023 | historical | 70 | 10
|
27-11-2023 | historical | 80 | 11 |
28-11-2023 | historical | 90 | 12 |
predicted | |||
lower | |||
upper |
Case 2 Table :
Date | Name | Cost | Part |
21-11-2023 | historical | 20 | 5 |
22-11-2023 | historical | 30 | 6 |
23-11-2023 | historical | 40 | 7 |
24-11-2023 | historical | 50 | 8 |
25-11-2023 | historical | 60 | 9 |
26-11-2023 | historical | 70 | 10 |
27-11-2023 | historical | 80 | 11 |
28-11-2023 | historical | 90 | 12 |
29-11-2023 | forecast | 100 | 13 |
29-11-2023 | lower | 98 | 12.5 |
29-11-2023 | upper | 102 | 13.5 |
30-11-2023 | predicted | 110 | 14 |
30-11-2023 | lower | 108 | 13.5 |
30-11-2023 | upper | 112 | 14.5 |
Case 3 table
Date | Name | Cost | Part |
29-11-2023 | predicted | 100 | 10 |
29-11-2023 | lower | 98 | 8 |
29-11-2023 | upper | 102 | 12 |
30-11-2023 | predicted | 110 | 12 |
30-11-2023 | lower | 108 | 10 |
30-11-2023 | upper | 112 | 14 |
I am new to Power BI but I need to do this report. Above is a table and I want to create a table with a only row selected from this table.
The conditions are:
One point to be noted is that in the first case, the date value is also not there for the predicted, upper, and lower names.
I am using power query to get the data with post request so it would be nice if I could use this calculation after retrieving the data in the power query itself.
Expected outcome:
In the first case :
28-11-2023 | historical | 90 | 12 |
In the second case :
28-11-2023 | historical | 90 | 12 |
In the third case :
29-11-2023 | predicted | 100 | 10 |
Solved! Go to Solution.
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-...
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/1447...
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
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.
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.
Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.
I updated the question. I added a new condition for more clarity.
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)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
123 | |
85 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |