Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi all,
I would like to display two time series in a normalized way to see their performance relative to each other. Think about two stocks (e.g. Apple vs. Microsoft) and I would like to visualized which stock performs better in this year.
An example what I look for
The "problem" is that each time I change the date range, for which the data is displayed, the normalization to zero percent has to be recalculated since it depends on the visual.
My tables and model look like this
Please find the full model and data at https://drive.google.com/file/d/1dU_ZGyb9QjeWbM-etW83Vq9D_l-ljMr5/view?usp=sharing
My problem is somehow similar as https://community.powerbi.com/t5/Desktop/Normalize-time-series-data-to-first-non-zero/m-p/598559#M28... from @Anonymous but the solution doesn't work for my case.
I tried (as newbie) myself to create a line chart based on the above mentioned solution but I cannot get it to work despite using around 20 hours for it. My code looks like this but isn't working.
ChangeIndex% =
VAR a =
CALCULATE (
MAX ( 'IndexData'[index1_close] ),
FILTER (
'IndexData',
'IndexData'[DateIndex] = MIN ( 'IndexData'[DateIndex] )
)
)
VAR mindate =
CALCULATE (
MIN ( 'IndexData'[DateIndex] ),
ALLSELECTED ( 'IndexData'[DateIndex] )
)
VAR firstrecord =
CALCULATE (
MAX ( 'IndexData'[index1_close]),
FILTER (
ALLSELECTED ( 'IndexData' ),
'IndexData'[DateIndex] = mindate)
)
RETURN
DIVIDE ( a - firstrecord, firstrecord )
My two problems with the code are
Any help would be appreciated! Thank you!
Solved! Go to Solution.
I looked at your file. A few comments
Rel Change 1 =
VAR vThisValue =
MAX ( IndexData[index1_close] )
VAR vFirstDate =
CALCULATE ( MIN ( IndexData[DateIndex] ), ALLSELECTED ( IndexData[DateIndex] ) )
VAR vFirstClose =
CALCULATE (
MAX ( IndexData[index1_close] ),
ALL ( 'Date' ),
IndexData[DateIndex] = vFirstDate
)
RETURN
DIVIDE ( vThisValue - vFirstClose, vFirstClose )
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
I looked at your file. A few comments
Rel Change 1 =
VAR vThisValue =
MAX ( IndexData[index1_close] )
VAR vFirstDate =
CALCULATE ( MIN ( IndexData[DateIndex] ), ALLSELECTED ( IndexData[DateIndex] ) )
VAR vFirstClose =
CALCULATE (
MAX ( IndexData[index1_close] ),
ALL ( 'Date' ),
IndexData[DateIndex] = vFirstDate
)
RETURN
DIVIDE ( vThisValue - vFirstClose, vFirstClose )
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thank you so much, Pat.
Great solution, thank you so much! I just found one little thing that needs to be changed from your script. In your script, when I change the data it does not normalize to zero to the new data but it normalizes to the first date (end of 2019).
Original version:
With a little change, I get the desired result:
The change from PAT's DAX is as follows:
Rel Change 1 =
VAR vThisValue =
MAX ( IndexData[index1_close] )
VAR vFirstDate =
CALCULATE ( MIN ( IndexData[DateIndex] ), ALLSELECTED( IndexData[DateIndex] ) )
VAR vFirstClose =
CALCULATE (
MAX ( IndexData[index1_close] ),
ALL ( 'Date' ),
IndexData[DateIndex] = vFirstDate
)
RETURN
DIVIDE ( vThisValue - vFirstClose, vFirstClose )
The Change is from
ALL
to
ALLSELECTED
@mahoneypat: Could you, please, update your post with this change so that people later find this change in the accepted solution?
Glad it worked. Updated with ALLSELECTED.
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 37 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 130 | |
| 88 | |
| 82 | |
| 68 | |
| 64 |