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 have a table below:
I need to create a end data column as:
The end data is calculated as:
1- If exist a new status each id, the end data is equal a first data de next status.
2- If not exist a new status, the end data is equal a data now.
I need to build this columns in power bi query, but i don´t can it.
Someone can help me please?
Solved! Go to Solution.
Hi @Anonymous
You could also do this in DAX but if you need in in PQ, place the following M code in a blank query to see the steps:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIEYkN9Q30jAyMDpVidaCUjqKCxvilC0BgqaKpvhiroBNJupG+Bqh8kagYXjAUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Status = _t, #"First data" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Status", type text}, {"First data", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let aux_ = Table.SelectRows(#"Changed Type", (inner)=> inner[Status]<>[Status] and inner[First data] > [First data] and inner[ID]=[ID])[First data], res_ = if List.Count(aux_) = 0 then "now" else List.Min(aux_) in res_, type text)
in
#"Added Custom"
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
@Anonymous
See it all at work in the attached file.
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Hi,
This calculated column formula works
=if(CALCULATE(COUNTROWS(Data),FILTER(Data,Data[ID]=EARLIER(Data[ID])&&Data[First Data]>EARLIER(Data[First Data])))<1,today(),CALCULATE(min(Data[First Data]),FILTER(Data,Data[ID]=EARLIER(Data[ID])&&Data[First Data]>EARLIER(Data[First Data]))))
Hope this helps.
@Anonymous
See it all at work in the attached file.
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Try removing the double quotes around your column names when inside the [ ] in the #"Added Custom" step.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Hi @Anonymous
You could also do this in DAX but if you need in in PQ, place the following M code in a blank query to see the steps:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIEYkN9Q30jAyMDpVidaCUjqKCxvilC0BgqaKpvhiroBNJupG+Bqh8kagYXjAUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Status = _t, #"First data" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Status", type text}, {"First data", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let aux_ = Table.SelectRows(#"Changed Type", (inner)=> inner[Status]<>[Status] and inner[First data] > [First data] and inner[ID]=[ID])[First data], res_ = if List.Count(aux_) = 0 then "now" else List.Min(aux_) in res_, type text)
in
#"Added Custom"
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Error appears, when I adapted for my table.
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 |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |