Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I would like to create a new column that stores only the first average value of a date and fills the rest with 0. How do I do this?
Solved! Go to Solution.
Hi, @gelsonwj
You need to add an index column to the power query first.
Column:
Average =
Var _Aver=CALCULATE(AVERAGE('Table'[Quantity]),ALLEXCEPT('Table','Table'[Date_short]))
Var _minindex=CALCULATE(MIN('Table'[Index]),ALLEXCEPT('Table','Table'[Date_short]))
Return
IF([Index]=_minindex,_Aver,0)
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @gelsonwj
You need to add an index column to the power query first.
Column:
Average =
Var _Aver=CALCULATE(AVERAGE('Table'[Quantity]),ALLEXCEPT('Table','Table'[Date_short]))
Var _minindex=CALCULATE(MIN('Table'[Index]),ALLEXCEPT('Table','Table'[Date_short]))
Return
IF([Index]=_minindex,_Aver,0)
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @gelsonwj
please try
First Average =
VAR CurrentID = 'Table'[id]
VAR DateFarmIDTable =
CALCULATETABLE (
'Table',
ALLEXCEPT ( 'Table', 'Table'[Farm_id], 'Table'[Date_short] )
)
VAR FirstRecord =
TOPN ( 1, DateFarmIDTable, 'Table'[id] )
VAR MaxID =
MAXX ( FirstRecord, 'Table'[id] )
VAR FirstAverage =
MAXX ( FirstRecord, 'Table'[Average] )
RETURN
IF ( 'Table'[id] = MaxID, FirstAverage, 0 )
hi @gelsonwj
try to add a column with this:
Average2 =
VAR _average = [Average]
VAR _MaxID =
MAXX(
FILTER(TableName, TableName[Average] = _average ),
TableName[id]
)
RETURN
IF( [id] = _MaxID, _average, 0)
User | Count |
---|---|
25 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
27 | |
13 | |
13 | |
10 | |
6 |