Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
I have a table with a Working Days column, which is integer type, and a Latest Action Date column with date (01/01/2020). I want a DAX measure to calculate the average but only for 2020 dates.
Latest Submission Date | Latest Action Date | Working Days |
4/1/2020 | 4/4/2020 | 4 |
4/3/2020 | 4/5/2020 | 2 |
1/4/2021 | 1/5/2021 | 1 |
I tried the following measures I wrote:
Got this error though both times:
Error Message:
MdxScript(Model) (35, 60) Calculation error in measure 'Pivoted Audit Log'[2020 Avg SLA Fixed]: DAX comparison operations do not support comparing values of type Text with values of type Number. Consider using the VALUE or FORMAT function to convert one of the values.
My objective:
A measure that calculates the average in a column, but only for year 2020, and then, another measure that calculates the average in a column but only for year 2021
Solved! Go to Solution.
@Anonymous , you can create a new column like
Work Day =
Var _end = if([Latest Action Date] > Date(2020,12,31),Date(2020,12,31), [Latest Action Date])
return
COUNTROWS(FILTER(ADDCOLUMNS(CALENDAR(Table[Latest Submission Date])_end),"WorkDay", if(WEEKDAY([Date],2) <6,1,0)),[WorkDay] =1))
or measure with some group by row id
Work Day =
Var _end = if(max([Latest Action Date]) > Date(2020,12,31),Date(2020,12,31), max[Latest Action Date]))
return
AverageX(Values(Table[RowID]), COUNTROWS(FILTER(ADDCOLUMNS(CALENDAR(max(Table[Latest Submission Date]),_end),"WorkDay", if(WEEKDAY([Date],2) <6,1,0)),[WorkDay] =1)))
@Anonymous , you can create a new column like
Work Day =
Var _end = if([Latest Action Date] > Date(2020,12,31),Date(2020,12,31), [Latest Action Date])
return
COUNTROWS(FILTER(ADDCOLUMNS(CALENDAR(Table[Latest Submission Date])_end),"WorkDay", if(WEEKDAY([Date],2) <6,1,0)),[WorkDay] =1))
or measure with some group by row id
Work Day =
Var _end = if(max([Latest Action Date]) > Date(2020,12,31),Date(2020,12,31), max[Latest Action Date]))
return
AverageX(Values(Table[RowID]), COUNTROWS(FILTER(ADDCOLUMNS(CALENDAR(max(Table[Latest Submission Date]),_end),"WorkDay", if(WEEKDAY([Date],2) <6,1,0)),[WorkDay] =1)))
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
126 | |
78 | |
78 | |
59 | |
51 |
User | Count |
---|---|
164 | |
84 | |
68 | |
68 | |
58 |