Forum Discussion
Display latest data compared to earliest data
- 1 year ago
Hey AngelaB ,
You're off to a great start already! Your approach of identifying the baseline and latest timepoints is logical and works well, especially for someone new to Power BI and DAX. That said, your solution can be improved slightly for performance, readability, and maintainability.
DAX for Include in Graph
Include in graph = VAR CurrentLocation = 'Table'[Location] VAR CurrentTimepoint = 'Table'[Timepoint] VAR MaxTimepoint = CALCULATE( MAX('Table'[Timepoint]), ALLEXCEPT('Table', 'Table'[Location]) ) RETURN SWITCH( TRUE(), CurrentTimepoint = 1, 1, -- Baseline CurrentTimepoint = MaxTimepoint, 2, -- Latest -1 -- Other )Visual Setup Tips:
Use this column (Include in graph) as a visual-level filter, keeping only values 1 (baseline) and 2 (latest).
You can also create a new column or measure to label the timepoints like 'Baseline', 'Latest', and use that in a legend or axis for clarity.
If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.
Best Regards,
Nasif Azam
Hey AngelaB ,
You're off to a great start already! Your approach of identifying the baseline and latest timepoints is logical and works well, especially for someone new to Power BI and DAX. That said, your solution can be improved slightly for performance, readability, and maintainability.
DAX for Include in Graph
Include in graph =
VAR CurrentLocation = 'Table'[Location]
VAR CurrentTimepoint = 'Table'[Timepoint]
VAR MaxTimepoint =
CALCULATE(
MAX('Table'[Timepoint]),
ALLEXCEPT('Table', 'Table'[Location])
)
RETURN
SWITCH(
TRUE(),
CurrentTimepoint = 1, 1, -- Baseline
CurrentTimepoint = MaxTimepoint, 2, -- Latest
-1 -- Other
)Visual Setup Tips:
Use this column (Include in graph) as a visual-level filter, keeping only values 1 (baseline) and 2 (latest).
You can also create a new column or measure to label the timepoints like 'Baseline', 'Latest', and use that in a legend or axis for clarity.
If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.
Best Regards,
Nasif Azam
- AngelaB1 year agoHelper I
Yes, thank you, this works and is a more elegant solution to my clunky multiple columns! Thank you for taking the time to review this for me.