I recently received an example from Sam I do not understand. Not afraid to say it. This is about calculating the number of days between dates. The code:(Copied hastily)
= var indexnum = max(data(index)) var previous index = calculate(max data(index), filter allselected(data) data(index) < indexnum var currentdate = value(selectedvalue(data(purchasedate)) var prior date = value(calculate(selectedvalue(data(purchase date), filter(all(data) data(index) = previous index return if (indexnum = calculate(min(data(index), allselected(data) ),0, current date - prior date
The if statement makes no sense to me. In the variable the indexnum is initially set to MAX(index). When the If is executed, it is assumed indexnum is looking at the first selected index(MIN)……not the MAX thus returning 0. I am new to DAX…what am I missing about how this statement works? How is Indexnum set each time if it always starts at MAX? Thanks!