Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have this table:
I want to compare the Invoice Date Column vs the Change Date Time Column and then return the Last Daily Change for the Change Date Time that has the closest before value.
In this example below:
Invoice Date: 1/15/2021
Closest before Change Date and Time: 6/14/19 15:17
Last Daily Change: .4495
I would like to create this as a DAX measure and insert the Last Daily Change Value into an existing visual on my dashboard that is showing Invoice#, Invoice date and some other sales information.
INVOICE | INVOICE DATE | Part # | LINE | FIELD_NAME | BEFORE | AFTER | DATE_CHG | Last Daily Change | Changed Date Time |
22555 | 1/15/21 | 100-1 | 100 | Rate | 0.415 | 2/8/19 | 0.415 | 2/8/19 11:09 | |
22555 | 1/15/21 | 100-1 | 100 | Rate | 0.415 | 0.49 | 2/13/19 | 0.49 | 2/13/19 6:27 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 0.49 | 0.5195 | 2/27/19 | 0.5195 | 2/27/19 12:19 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 0.5195 | 0.4495 | 6/14/19 | 0.4495 | 6/14/19 15:17 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 0.4495 | 0.91 | 5/17/21 | 0.91 | 5/17/21 10:48 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 0.91 | 1.12 | 9/22/21 | 1.12 | 9/22/21 16:30 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 1.12 | 0.4495 | 12/3/21 | 1.12 | 12/3/21 7:28 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 0.4495 | 1.12 | 12/3/21 | 1.12 | 12/3/21 7:30 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 1.12 | 0.4495 | 12/10/21 | 1.12 | 12/10/21 6:53 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 0.4495 | 0.91 | 12/10/21 | 1.12 | 12/10/21 7:10 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 0.91 | 1.12 | 12/10/21 | 1.12 | 12/10/21 7:12 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 1.12 | 0.91 | 12/10/21 | 1.12 | 12/10/21 7:18 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 0.91 | 1.12 | 12/10/21 | 1.12 | 12/10/21 7:19 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 1.12 | 0.4395 | 1/26/22 | 1.12 | 1/26/22 16:09 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 0.4395 | 0.8455 | 1/26/22 | 1.12 | 1/26/22 16:42 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 0.8455 | 0.91 | 1/26/22 | 1.12 | 1/26/22 16:43 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 0.91 | 0.965 | 1/26/22 | 1.12 | 1/26/22 16:44 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 0.965 | 1.02 | 1/26/22 | 1.12 | 1/26/22 16:45 |
22555 | 1/15/21 | 100-1 | 100 | Rate | 1.02 | 1.12 | 1/26/22 | 1.12 | 1/26/22 16:46 |
Solved! Go to Solution.
Hi @Swilson2112 ,
You may try this Measure.
Last Daily Change Value =
VAR max_date =
MAXX (
FILTER ( 'Table', 'Table'[INVOICE DATE] > 'Table'[Changed Date Time] ),
'Table'[Changed Date Time]
)
RETURN
CALCULATE (
MAX ( 'Table'[Last Daily Change] ),
FILTER ( 'Table', 'Table'[Changed Date Time] = max_date ),
VALUES ( 'Table'[INVOICE] )
)
Then, the result will look like this.
Also, attached the pbix file as reference.
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!
Best Regards,
Community Support Team _ Caiyun
Hi @Swilson2112 ,
You may try this Measure.
Last Daily Change Value =
VAR max_date =
MAXX (
FILTER ( 'Table', 'Table'[INVOICE DATE] > 'Table'[Changed Date Time] ),
'Table'[Changed Date Time]
)
RETURN
CALCULATE (
MAX ( 'Table'[Last Daily Change] ),
FILTER ( 'Table', 'Table'[Changed Date Time] = max_date ),
VALUES ( 'Table'[INVOICE] )
)
Then, the result will look like this.
Also, attached the pbix file as reference.
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!
Best Regards,
Community Support Team _ Caiyun
User | Count |
---|---|
25 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
27 | |
13 | |
11 | |
9 | |
6 |