Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Using a data set with a structure like below, I am trying to determine if a value related to a certain field, in this case id, is either rising or falling. We are using the most recent value and the value prior to the last one to determine that. In the example below, the latest value is 2 and the previous value is 0, so the change metric on this would equal 2, so the value would be defined as "rising".
personid | Date | Value | |
10 | 1/14/2020 | 0 | |
10 | 1/29/2020 | 1 | |
10 | 2/13/2020 | 1 | |
10 | 2/28/2020 | 2 | |
10 | 3/14/2020 | 1 | |
10 | 3/29/2020 | 0 | |
10 | 4/13/2020 | 2 |
personid | Date | Value | date_rank | latest_value | previous_value | Rising Falling Stable |
10 | 1/14/2020 | 0 | 7 | |||
10 | 1/29/2020 | 1 | 6 | |||
10 | 2/13/2020 | 1 | 5 | |||
10 | 2/28/2020 | 2 | 4 | |||
10 | 3/14/2020 | 1 | 3 | |||
10 | 3/29/2020 | 0 | 2 | 0 | 0 | |
10 | 4/13/2020 | 2 | 1 | 2 | 2 |
Do anyone know how I can get the previous and current metrics into the same row in this table so I can get a change since previous date metric to be showing in the Rising Falling Stable column?
Solved! Go to Solution.
Here is a measure expression you can use in a Table visual with the PersonID column to get your desired result.
Trend =
VAR latestdate =
MAX ( 'Cases'[Date] )
VAR prevdate =
CALCULATE ( MAX ( 'Cases'[Date] ), 'Cases'[Date] < latestdate )
VAR latestvalue =
CALCULATE ( SUM ( 'Cases'[Value] ), 'Cases'[Date] = latestdate )
VAR prevvalue =
CALCULATE ( SUM ( 'Cases'[Value] ), 'Cases'[Date] = prevdate )
RETURN
SWITCH (
TRUE (),
latestvalue > prevvalue, "Rising",
latestvalue < prevvalue, "Falling",
"Stable"
)
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Here is a measure expression you can use in a Table visual with the PersonID column to get your desired result.
Trend =
VAR latestdate =
MAX ( 'Cases'[Date] )
VAR prevdate =
CALCULATE ( MAX ( 'Cases'[Date] ), 'Cases'[Date] < latestdate )
VAR latestvalue =
CALCULATE ( SUM ( 'Cases'[Value] ), 'Cases'[Date] = latestdate )
VAR prevvalue =
CALCULATE ( SUM ( 'Cases'[Value] ), 'Cases'[Date] = prevdate )
RETURN
SWITCH (
TRUE (),
latestvalue > prevvalue, "Rising",
latestvalue < prevvalue, "Falling",
"Stable"
)
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
13 | |
12 | |
11 | |
11 | |
8 |