Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
pmadam
Helper II
Helper II

DAX hELP

I have a calculated measure.

 

_DATE CHECK = IF('Union Table'[AddedDate] = CALCULATE(MIN('Union Table'[AddedDate]),ALLEXCEPT('Union Table','Union Table'[OrderNumber])),"OLDEST DATE","NOT OLDEST DATE")

 

 

I am trying to create a custom column in Power Query editor and Filter out the data "NOT OLDEST DATE" but Im not not able create a custom colunmn. Please help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @pmadam ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XdDLCcQwDATQXnIORKOPP1VsASG3rWD7P6wjg2x0MTY8RmPd9/H5fQnHediFi4l5XFH0PbWM13PuRILUNokikbJS7D2ZRBOpQTBTpJcg7KQFkeLEYIn0ICoOzVaKpLpGDiGUyFa3z3E9p4DXJO8r2Baj06xRgBuyGsamWf/ubpRqNkxhmvexxmPDzx8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [OrderNumber = _t, AddedDate = _t, Qty = _t, Sales = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"OrderNumber", type text}, {"AddedDate", type date}, {"Qty", Int64.Type}, {"Sales", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"OrderNumber"}, {{"Mindate", each List.Min([AddedDate]), type nullable date}, {"Details", each _, type table [OrderNumber=nullable text, AddedDate=nullable date, Qty=nullable number, Sales=nullable number]}}),
    #"Expanded Details" = Table.ExpandTableColumn(#"Grouped Rows", "Details", {"AddedDate", "Qty", "Sales"}, {"AddedDate", "Qty", "Sales"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Details", "_DATE CHECK", each if [AddedDate]=[Mindate] then "OLDEST DATE" else "NOT OLDEST DATE"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Mindate"})
in
    #"Removed Columns"

yingyinr_0-1654061649804.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @pmadam ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XdDLCcQwDATQXnIORKOPP1VsASG3rWD7P6wjg2x0MTY8RmPd9/H5fQnHediFi4l5XFH0PbWM13PuRILUNokikbJS7D2ZRBOpQTBTpJcg7KQFkeLEYIn0ICoOzVaKpLpGDiGUyFa3z3E9p4DXJO8r2Baj06xRgBuyGsamWf/ubpRqNkxhmvexxmPDzx8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [OrderNumber = _t, AddedDate = _t, Qty = _t, Sales = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"OrderNumber", type text}, {"AddedDate", type date}, {"Qty", Int64.Type}, {"Sales", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"OrderNumber"}, {{"Mindate", each List.Min([AddedDate]), type nullable date}, {"Details", each _, type table [OrderNumber=nullable text, AddedDate=nullable date, Qty=nullable number, Sales=nullable number]}}),
    #"Expanded Details" = Table.ExpandTableColumn(#"Grouped Rows", "Details", {"AddedDate", "Qty", "Sales"}, {"AddedDate", "Qty", "Sales"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Details", "_DATE CHECK", each if [AddedDate]=[Mindate] then "OLDEST DATE" else "NOT OLDEST DATE"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Mindate"})
in
    #"Removed Columns"

yingyinr_0-1654061649804.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

amitchandak
Super User
Super User

@pmadam , This DAX formula and correct with you min at order number

 


_DATE CHECK = IF('Union Table'[AddedDate] = CALCULATE(MIN('Union Table'[AddedDate]),ALLEXCEPT('Union Table','Union Table'[OrderNumber])),"OLDEST DATE","NOT OLDEST DATE")

 

or

 

 

_DATE CHECK = IF('Union Table'[AddedDate] = MINX(filter('Union Table','Union Table'[OrderNumber] =earlier('Union Table'[OrderNumber])) 'Union Table'[AddedDate]),"OLDEST DATE","NOT OLDEST DATE")

 

or, if you need over all min


_DATE CHECK = IF('Union Table'[AddedDate] = Min('Union Table'[AddedDate]) ,"OLDEST DATE","NOT OLDEST DATE")

 

 

For overall min in power query, you can use List.Min

 

refer List.Min and List.MinN: https://youtu.be/9wYdttOPWaQ

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.