Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi All,
I have a measure that calculates the absolute change of another measure between the MIN & MAX selected date.
The problem is that once the other measure returns blank for the MIN date/MAX date , the absolute change calculation is not what I expect to get. In such cases I would like to enforce my measure to take the value of the first date that does not evaluate to BLANK (in case of MIN date), or take the last date that does not evaluate to BLANK (in case of MAX date). How can I do that using DAX?
Hi, @MichaelStrauss
Here are the steps you can refer to :
(1)This is my test data:
(2)We can create a measure :
Measure = var _max_slice = MAX('Sheet1'[Date])
var _min_slice = MIN('Sheet1'[Date])
var _table = FILTER(ALL('Sheet1') , 'Sheet1'[Date] >= _min_slice && 'Sheet1'[Date] <=_max_slice && 'Sheet1'[Value] <> BLANK())
var _min_date = MINX(_table , [Date])
var _max_date =MAXX(_table , [Date])
var _first_value =SUMX( FILTER( ALL('Sheet1') , 'Sheet1'[Date]= _min_date) , [Value])
var _last_value = SUMX( FILTER( ALL('Sheet1') , 'Sheet1'[Date]= _max_date) , [Value])
return
ABS(_last_value-_first_value)
(3)Then we can meet your need , the result is as follows:
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @v-yueyunzh-msft
Thank you for your answer. It did give me a solution to the absolute stock-change measure. That question that arises, what if I have a more complicated measure that is using multiple columns and also some time-intelligenece formula? Then I'm not able to use the same logic as in the VAR _table, I can't put a certain column that will not be equal to blank.
Here is my 'complicated' measure:
So basically I would like to calculate the change of this measure between the Max selected date and the Min selected date, but as requested if one of them avaluates to BLANK, I want it to take the nearest month where the measure does not evaluate to BLANK
My Data-Set looks like this:
Sku No | Period Date | Stock value | Issue total stock value |
1 | 01/01/2021 | ||
2 | 01/01/2021 | ||
3 | 01/01/2021 | ||
1 | 01/02/2021 | ||
2 | 01/02/2021 | ||
3 | 01/02/2021 | ||
1 | 01/03/2021 | ||
2 | 01/03/2021 | ||
3 | 01/03/2021 | ||
1 | 01/04/2021 | ||
2 | 01/04/2021 | ||
3 | 01/04/2021 | ||
1 | 01/05/2021 | ||
2 | 01/05/2021 | ||
3 | 01/05/2021 |