Forum Discussion
Create Measure for finding most recent value
- Anonymous7 years ago
This will bring in the last quality value depeding on what product is being used:
Measure = CALCULATE( SUM ( CRM[Quality] ), LASTDATE(CRM[Date ] ))
- Anonymous7 years ago
I decided to go the Power query route for this one. I tried using just DAX and just wasnt working for me. So here's what I did in Power Query ( the pbix is attached below so you can step through the applied steps(:
- Found the Max Data of the table
- Grouped the table by Products, and added a column for the Max Date of that product
- Expand that data out, so have the date of the row, the max date of the entire table and the max date for that product
- Added a custom column to figure what End date to use for each row
if [#"Date "] < [Max Product Date] then Date.AddDays( [Max Product Date], -1) else [Max of Table]
- Removed some misc columns and added a new column to get a list of dates from the date of the actual row to end date as defined by # 5 above
List.Dates( [#"Date "], Duration.Days( [End Date] - [#"Date "]) +1 , #duration(1,0,0,0) )
- That will produce a list of all the days between those two days for each product. Expand that list out
- End table looks like this:
What this is doing is making sure every day is accounted for and will "bring in" the last value.
Load that in, and then write the following measure:
Total Quantity = IF( ISFILTERED('CRM (3)'[Dates]), SUM ( 'CRM (3)'[Quality] ), "Please Select a Date" )Now, dont want to sum across days since that would not make sense ( and now that i think about it, probbaly could use lastdate, but this works too)
pbix is here:
https://1drv.ms/u/s!Amqd8ArUSwDSz0IOCvktg-arAeCk
This will bring in the last quality value depeding on what product is being used:
Measure = CALCULATE( SUM ( CRM[Quality] ), LASTDATE(CRM[Date ] ))
- mussaenda2 years agoCommunity Champion
Who would have thought that it is as simple as this.
Thanks for sharing!