Forum Discussion
Deltas within a Measure (?)
- 1 year ago
Hi Pfoster ,
To calculate the deltas between periods in your chart using the existing YaQ_Volume measure, you can create a separate DAX measure that captures the previous period’s value and computes the percentage change. Assuming your 'Unrelated Date'[Period] column contains sortable numeric values (e.g., 2020, 2021, or Q1 as 1, Q2 as 2, etc.), use the following DAX:
YaQ_Delta = VAR CurrentValue = [YaQ_Volume] VAR PrevValue = CALCULATE( [YaQ_Volume], FILTER( ALL('Unrelated Date'), 'Unrelated Date'[Category] = MAX('Unrelated Date'[Category]) && 'Unrelated Date'[Period] = MAX('Unrelated Date'[Period]) - 1 ) ) RETURN IF( NOT ISBLANK(PrevValue), DIVIDE(CurrentValue - PrevValue, PrevValue), BLANK() )This measure evaluates the current value and compares it to the previous period’s value by subtracting one from the current 'Unrelated Date'[Period]. It returns the percentage difference. If the previous value is blank, the measure returns blank to avoid misleading percentages. You can then display this measure as a tooltip or data label in your visual. If your period column is not numeric, this logic will need to be adjusted using a rank or index to establish chronological order.
Best regards,
Hi Pfoster ,
To calculate the deltas between periods in your chart using the existing YaQ_Volume measure, you can create a separate DAX measure that captures the previous period’s value and computes the percentage change. Assuming your 'Unrelated Date'[Period] column contains sortable numeric values (e.g., 2020, 2021, or Q1 as 1, Q2 as 2, etc.), use the following DAX:
YaQ_Delta =
VAR CurrentValue = [YaQ_Volume]
VAR PrevValue =
CALCULATE(
[YaQ_Volume],
FILTER(
ALL('Unrelated Date'),
'Unrelated Date'[Category] = MAX('Unrelated Date'[Category]) &&
'Unrelated Date'[Period] = MAX('Unrelated Date'[Period]) - 1
)
)
RETURN
IF(
NOT ISBLANK(PrevValue),
DIVIDE(CurrentValue - PrevValue, PrevValue),
BLANK()
)
This measure evaluates the current value and compares it to the previous period’s value by subtracting one from the current 'Unrelated Date'[Period]. It returns the percentage difference. If the previous value is blank, the measure returns blank to avoid misleading percentages. You can then display this measure as a tooltip or data label in your visual. If your period column is not numeric, this logic will need to be adjusted using a rank or index to establish chronological order.
Best regards,