Forum Discussion
Values not getting added in TOTALS
- 2 years ago
Hi All,
Issue is resolved by using this below measure
Total_MTD_YTD =IF(ISINSCOPE('Table'[Countries]),[Day_Target],CALCULATE(SUMX(ALL('Table'[Countries]),[Day_Target])))Thank you all. - 2 years ago
Hi Anonymous ,
In the Sample file which you published, the data is getting like this.
But I need like this
By using first two measures, I didn't get the expected result.
Day.Target = VAR SelectedDate = SELECTEDVALUE(DateTable[Date]) VAR SelectEdMonth = MONTH(SelectedDate) VAR SelectedYear = YEAR(SelectedDate) RETURN CALCULATE( ([On-Date Target]), 'DateTable'[Date] <= SelectedDate, 'DateTable'[Date] >= DATE(SelectedYear, SelectedMonth, 1) -- MTD )Day Target = VAR SelectedDate = MAX('DateTable'[Date]) VAR SelectedMonth = MONTH(SelectedDate) VAR SelectedYear = YEAR(SelectedDate) VAR MTD_Value = CALCULATE( [On-Date Target], DATESBETWEEN( 'DateTable'[Date], DATE(SelectedYear, SelectedMonth, 1), SelectedDate ) ) VAR YTD_Value = CALCULATE( [On-Date Target], DATESBETWEEN( 'DateTable'[Date], DATE(SelectedYear, 1, 1), SelectedDate ) )
But using third measure, I got the expected result.Day_Target = IF( ISINSCOPE('Table'[Countries]), [Day Target], CALCULATE( SUMX( ALL('Table'[Countries]), [Day Target] ) ) )I'm sharing my sample file,
Thank you all.
Hi Shaik_2002 ,
As far as I know, your issue should be caused by IF() function.
Here I have two workarounds:
1. You can sum [Day_Target] to get correct total directly.
New_Day_Target =
SUMX ( VALUES ( 'Table'[Citys] ), [Day_Target] )
2. You can create a virtual table in your calculation.
New_Day_Target =
VAR _Virtual =
SUMMARIZE (
'Table',
'Table'[Cities],
"Day_Target",
VAR SelectedDate =
SELECTEDVALUE ( 'DateTable'[Date] )
VAR SelectedMonth =
MONTH ( SelectedDate )
VAR SelectedYear =
YEAR ( SelectedDate )
RETURN
IF (
ISBLANK ( [On-Date Target] ),
CALCULATE (
[On-Date Target],
'DateTable'[Date] <= SelectedDate,
'DateTable'[Date] >= DATE ( SelectedYear, 1, 1 )
),
CALCULATE (
[On-Date Target],
'DateTable'[Date] <= SelectedDate,
'DateTable'[Date] >= DATE ( SelectedYear, SelectedMonth, 1 )
)
)
)
RETURN
SUMX ( _Virtual, [Day_Target] )
If this reply still couldn't help you solve your issue please share a sample file with us. This will make it easier for us to find the solution.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous,
Sorry for the delay, I have tried the formula which you have given and still it is not working.
I'm attaching the sample pbix file along with the sample excel data.
Thanks in Advance!!