Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 104 | |
| 81 | |
| 69 | |
| 50 | |
| 46 |