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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Ranking

PartDatetimeBeforeAfterDESIRED RESULT
a1/1/20229:00:00 AM 0.10
a1/1/20229:15:00 AM0.10.70
a1/1/202211:00:00 AM0.70.30
a1/1/20223:00:00 PM0.30.21
b1/5/20228:00:00 AM 10
b1/5/202211:30:00 AM150
b1/5/20224:00:00 PM530
b1/5/202211:00:00 PM321

 

I have this file. and I would like to know how to acheive the desired resluts column.  I have multiple parts that get changes made to the item file multiple times per day.  I would like to know which change was made last according to Date and Time combination.  Each part will need to have either a 0 or a 1 designator.

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous Maybe:

DESIRED RESULT column =
  VAR __Part = [Part]
  VAR __Date = [Date]
  VAR __time = [time]
  VAR __MaxDate = MAXX(FILTER('Table',[Part] = __Part),[Date])
  VAR __MaxTime = MAXX(FILTER('Table',[Part] = __Part && [Date] = __MaxDate),[time])
RETURN
  IF([Part] = __Part && [Date] = __Date && [time] = __time,1,0)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Swilson2112
Frequent Visitor

EXAMPLE of tables and desired result.

 

TABLE 1                                       

Transaction #.      Part#                           Invoice Date.

1.                             A                              02/14/2022

2.                             A                              02/02/2022

 

TABLE 2

Part#                            Chnage Date.           Change

A.                                   02/10/2022.                1.25

A                                    02/05/2022                 0.37

A                                    01/15/2022                 2.56

 

 

Desired Resultes

 

Transaction   Return Result.     Notes:

1                      1.25                Chnage date of 02/10/2022 is closest less than date from invoice date of 02/14/2022 

2                      2.56                Chnage date of 01/15/2022 is closest less than date from invoice date of 02/02/2022

Swilson2112
Frequent Visitor

I figured this part out.  Now I am trying to create a measure that compares the invoice date from table 1 with the closest lower Change date from table 2 and then returns the changed field from table 2. 

Swilson2112
Frequent Visitor

PartBefore After Date TimeDesired RandRank
A 0.4152/8/19 11:09     0
A 02/8/19 11:09     0
A 02/8/19 11:09     0
A 24.12/8/19 11:09     0
A 0.0652/8/19 11:09     0
A 103.52/8/19 11:09     0
A 103.52/8/19 11:09     0
A 46.52/8/19 11:09     0
A 36.52/8/19 11:09     0
A 36.52/8/19 11:09     0
A 36.52/8/19 11:09     0
A 36.52/8/19 11:09     0
A36.5 2/8/19 11:12     1
A0.4150.492/13/19 6:27     0
A103.576.52/13/19 6:29     0
A103.576.52/13/19 6:29     1 
A0.0650.08652/14/19 10:14     1
A0.490.51952/27/19 12:19     1
A 46.54/18/19 8:41     1
A0.51950.44956/14/19 15:17     1
A76.5103.52/20/20 16:03     0
A76.5103.52/20/20 16:03     1
A24.138.986/5/20 14:20     1
A0.44950.915/17/21 10:48     1
A0.911.129/22/21 16:30     1
A1.120.449512/3/21 7:28     0
A0.44951.1212/3/21 7:30     1
A1.120.449512/10/21 6:53     0
A0.44950.9112/10/21 7:10     0
A0.911.1212/10/21 7:12     0
A1.120.9112/10/21 7:18     0
A0.911.1212/10/21 7:19     1
A1.120.43951/26/22 16:09     0
A0.43950.84551/26/22 16:42     0
A0.84550.911/26/22 16:43     0
A0.910.9651/26/22 16:44     0
A0.9651.021/26/22 16:45     0
A1.021.121/26/22 16:46     1

 

OK, How do I create this desired result?  I have many parts and want the desired rank of either "0" or "1".  On the last combination of Part & DateTime for each specific day.  (See table above with Desired Result column that I manually populated.). I have multiple changes happening each day, but I only want to work with the last one of each day.  I will then need to compare the ship date of another table to the closest after date that contains a "1" and then ruturn the text volue of the After field. (Text field type because it is also other changes) from the above table.  I thought that I would need the 0's and 1's but if there is an easier way to do this I am more than willing to listen.

Anonymous
Not applicable

Thanks Greg.  This worked.

Greg_Deckler
Community Champion
Community Champion

@Anonymous Maybe:

DESIRED RESULT column =
  VAR __Part = [Part]
  VAR __Date = [Date]
  VAR __time = [time]
  VAR __MaxDate = MAXX(FILTER('Table',[Part] = __Part),[Date])
  VAR __MaxTime = MAXX(FILTER('Table',[Part] = __Part && [Date] = __MaxDate),[time])
RETURN
  IF([Part] = __Part && [Date] = __Date && [time] = __time,1,0)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

PartBefore CostAfter CostDate TimeDesired RandRank
A 0.4152/8/19 11:090
A 02/8/19 11:090
A 02/8/19 11:090
A 24.12/8/19 11:090
A 0.0652/8/19 11:090
A 103.52/8/19 11:090
A 103.52/8/19 11:090
A 46.52/8/19 11:090
A 36.52/8/19 11:090
A 36.52/8/19 11:090
A 36.52/8/19 11:090
A 36.52/8/19 11:090
A36.5 2/8/19 11:121
A0.4150.492/13/19 6:270
A103.576.52/13/19 6:290
A103.576.52/13/19 6:291
A0.0650.08652/14/19 10:141
A0.490.51952/27/19 12:191
A 46.54/18/19 8:411
A0.51950.44956/14/19 15:171
A76.5103.52/20/20 16:030
A76.5103.52/20/20 16:031
A24.138.986/5/20 14:201
A0.44950.915/17/21 10:481
A0.911.129/22/21 16:301
A1.120.449512/3/21 7:280
A0.44951.1212/3/21 7:301
A1.120.449512/10/21 6:530
A0.44950.9112/10/21 7:100
A0.911.1212/10/21 7:120
A1.120.9112/10/21 7:180
A0.911.1212/10/21 7:191
A1.120.43951/26/22 16:090
A0.43950.84551/26/22 16:420
A0.84550.911/26/22 16:430
A0.910.9651/26/22 16:440
A0.9651.021/26/22 16:450
A1.021.121/26/22 16:461

 

OK, How do I create this desired result?  I have many parts and want the desired rank of "1" on the last combination of Part & DateTime for each specific day.  (See table above with Desired Result column that I manually populated.)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.