Hoping someone can help me with something I can’t get my head around.
I’m trying to replicate that scenario with DAX to calculate percent change with a start value of a given set of data. In this case I want the start value to be dynamic based on the start date which is in turn selected via the date picker. See image below:
In the image, I have selected 03/08/2011 as my start date from the date picker. The value on this day is $8.88m. So what I want to do is have the measure ‘getting first value’ repeat for the whole table as indicated by the green highlight & arrow.
I thought removing all filters with ALL as indicated in the DAX measure I wrote would address this but not the case. It does seem to give the expected value only at the ‘Total’ row at the bottom.
My goal is to be able to subtract the first value from each row as a way of calculating the percent return since the first date. And with the date picker, a user should be able to dynamically view his / her return from a given start date.
What am I doing wrong?
Thanks in advance for your help & insights
You’re right – this one was trickier than it looked at first glance. Here’s a solution that works, though it took me three measures to get there. so probably not the most elegant or efficient approach:…
Thanks a mil to you both for looking into the issue. Really awesome!
Agreed with @BrianJ both solutions get to the finish line - the objective (I never got to the finish line! )
@Melissa I never imagined using DATEADD to get to the finish line. Can you please elaborate the logic behind for my learning / understanding? I’d much appreciate. The VAR ‘ThisDate’ seems to return blank, correct?
I visualized the elements used separately below, the VAR ‘ThisDate’ returns BLANK only when there is no Date context OR when more than one date is returned (like in the grand total row)
Here’s more on DATEADD
You can fix the grand total by switching to @BrianJ’s solution, something like:
The best of two worlds =
SWITCH ( HASONEVALUE ( Dates[Date] ),
TRUE(), [FirstDaySales],
FALSE(), [First Sales Selected]
)