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.
Hi,
I need to create a column based on the difference from column "Value", and the average value of the date range given in slicer. For example:
Actual Table
Date | Value |
2021-01-01 | 5 |
2021-01-02 | 10 |
2021-01-03 | 15 |
2021-01-04 | 20 |
In the slicer we selected the date range from '2021-01-01' to '2021-01-03' - The average for this interval is 10. My main problem is that I cannot use this value as a 'constant' (as in excel by using $). The new column should look like this:
Date | Value | New Col |
2021-01-01 | 5 | (5-10)^2 |
2021-01-02 | 10 | (10-10)^2 |
2021-01-03 | 15 | (15-10)^2 |
2021-01-04 | 20 | ?BLANK()? OR (20-10)^2 (but its important that the average is only calculated from the slicer) |
If we select another day in the slicer, the average is 12.5 and a new column should be calculated based on this value. For first day (5-12,5)^2 etc. I tried something like this but without any positive result:
x = AVERAGEX('TABLE',POWER('TABLE'[Value]-(CALCULATE(AVERAGE('TABLE'[Value]),DATESBETWEEN('Calendar Table'[Date],MIN('Calendar Table'[Date]),MAX('Calendar Table'[Date])))),2)) - Date from Calendar Table is used in the slicer.
Solved! Go to Solution.
@Chmielo
You can create a measure for this because a calculated column cannot access the values selected in the slicer.
New Value =
var _avg = CALCULATE( AVERAGE(Table1[Value]), ALLSELECTED(Table1[Date]) )
var _value =
AVERAGEX(
Table1,
(Table1[Value] - _avg ) ^ 2
)
return
_value
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@Chmielo
You can create a measure for this because a calculated column cannot access the values selected in the slicer.
New Value =
var _avg = CALCULATE( AVERAGE(Table1[Value]), ALLSELECTED(Table1[Date]) )
var _value =
AVERAGEX(
Table1,
(Table1[Value] - _avg ) ^ 2
)
return
_value
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
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 |
---|---|
12 | |
9 | |
9 | |
6 | |
5 |
User | Count |
---|---|
17 | |
15 | |
10 | |
9 | |
8 |