Forum Discussion
SPDA
1 year agoRegular Visitor
Help with adding if then statement?
Hello, I am new to creating measures and have hit a wall. Can anyone help? I've created a measure that works properly to calculate the sum of a field called AgrHrsCovered for Jan 2025 only. I...
- 1 year ago
Can you provide a sample of the data please? It may be better to use a calculated column that only performs the if statement, depending on how your data is presented
Here i've used the column
CalculatedColumn = IF('January2025Hours'[Hours] < 1, 1, 'January2025Hours'[Hours])to obtain the following results
Let me know if this fixes the issue, thanks
wardy912
1 year agoSuper User
Hi SPDA
Jan 2025 Hrs =
VAR TotalHrs =
CALCULATE (
SUM ('EHR Hours'[AgrHrsCovered]),
'EHR Hours'[Date Start] >= DATE(2025,1,1) &&
'EHR Hours'[Date Start] <= DATE(2025,1,31)
)
RETURN
IF (TotalHrs < 1, 1, TotalHrs)The return statement gives 1 if true, the actual sum if false.
Hope this helps, please mark as the solution and give a thumbs up if it does, thanks!