Forum Discussion
Need help creating a Delta column based on varying columns
I am trying to create a matrix/data table.
The Rows - the rows are metric names for my KPI funnel. The names are defined within a custom MetricName datatable. ("Impressions", "Clicks", "CTR"....etc.)
The columns - Fiscal Years that the user can select using a multiselect filter (the user should select only two of these)
The values - uses the SELECTEDVALUE and SWITCH functionalities to display the values for each KPI in the MetricName datatable, like so:
Values =
3 Replies
- Kedar_Pande
Super User
Anonymous
Create a Delta Measure:
Delta =
VAR SelectedYears = VALUES(YourYearTable[Year]) // Replace with your actual year table
VAR Year1 = SELECTEDVALUE(SelectedYears, 0, 1) // Get the first selected year
VAR Year2 = SELECTEDVALUE(SelectedYears, 1, 0) // Get the second selected year
RETURN
IF(
Year1 <> 0 && Year2 <> 0,
[Values for Year2] - [Values for Year1], // Replace with your measure for each selected year
BLANK()
)Adjust your existing values measure
Values_Year1 =
CALCULATE(
[Values],
FILTER(
'YourYearTable',
'YourYearTable'[Year] = SELECTEDVALUE(YourYearTable[Year], 0)
)
)Values_Year2 =
CALCULATE(
[Values],
FILTER(
'YourYearTable',
'YourYearTable'[Year] = SELECTEDVALUE(YourYearTable[Year], 1)
)
)πIf this helped, a Kudos π or Solution mark would be great! π
Cheers,
Kedar
Connect on LinkedIn - AnonymousNot applicable
I had something similar, but the column filter context made me return all zeroes for delta, so I used ALLSELECTED() to ignore the column fitler context:
YoY% Change = VAR AllYears = CALCULATETABLE(VALUES('AT_SEM_FISCAL_CALENDAR'[FY_N]), ALLSELECTED()) VAR MinYear = MINX(AllYears, 'AT_SEM_FISCAL_CALENDAR'[FY_N]) VAR MaxYear = MAXX(AllYears, 'AT_SEM_FISCAL_CALENDAR'[FY_N]) VAR Values_Year1 = CALCULATE( [Values], 'AT_SEM_FISCAL_CALENDAR'[FY_N] = MinYear ) VAR Values_Year2 = CALCULATE( [Values], 'AT_SEM_FISCAL_CALENDAR'[FY_N] = MaxYear ) RETURN IF( Values_Year1 <> 0, (Values_Year2 - Values_Year1) / Values_Year1, BLANK())The only issue now is im getting duplicate delta columns, presumable because there's a %YoY change/Delta for each fiscal year column. How do i remove the first one?
- AnonymousNot applicable
Hi Anonymous ,
According to your statement, I think you can try to DIY "Column Subtotal" in visual format.
Firstly, change the Subtotal label as "YoY% Change".
Then create a new measure based on [Values] measure.
Measure = VAR AllYears = CALCULATETABLE(VALUES('AT_SEM_FISCAL_CALENDAR'[FY_N]), ALLSELECTED()) VAR MinYear = MINX(AllYears, 'AT_SEM_FISCAL_CALENDAR'[FY_N]) VAR MaxYear = MAXX(AllYears, 'AT_SEM_FISCAL_CALENDAR'[FY_N]) VAR Values_Year1 = CALCULATE( [Values], 'AT_SEM_FISCAL_CALENDAR'[FY_N] = MinYear ) VAR Values_Year2 = CALCULATE( [Values], 'AT_SEM_FISCAL_CALENDAR'[FY_N] = MaxYear ) RETURN IF(HASONEVALUE(AT_SEM_FISCAL_CALENDAR[FY_N]),[Values],(Values_Year2 - Values_Year1) / Values_Year1)Use this measure in matrix value field. Then we need to create a measure for dynamic data format.
IF(HASONEVALUE(AT_SEM_FISCAL_CALENDAR[FY_N]),"0.00","0.00%")Result is as below.
You can download my sample file to learn more details.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.