Forum Discussion
Row level Subtotal Error
- Anonymous1 year ago
Hi Karthick1006 ,
You can achieve this by first creating a calculated column to get the latest record for each country. Then, build a measure that calculates the valid percentage using only those latest records. This way, your row-level and region-level totals will reflect only the most recent data per country. Here's a rough idea of how the logic works:
Please create a calculated column as belolw:
IsLatestRecord =
VAR CurrentDate = 'Table'[Date]
VAR Country = 'Table'[Country]
VAR MaxDate =
CALCULATE (
MAX ( 'Table'[Date] ),
ALLEXCEPT ( 'Table', 'Table'[Country] )
)
RETURN IF ( CurrentDate = MaxDate, 1, 0 )
Then create a measure as below:ValidCustomer% (Latest Only) =
VAR LatestData =
FILTER (
'Table',
'Table'[IsLatestRecord] = 1
)
VAR TotalValid = SUMX ( LatestData, 'Table'[records_valid] )
VAR TotalCount = SUMX ( LatestData, 'Table'[records_count] )
RETURN DIVIDE ( TotalValid, TotalCount ) * 100If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Regards,
B Manikanteswara Reddy
Hi Karthick1006 ,
You can achieve this by first creating a calculated column to get the latest record for each country. Then, build a measure that calculates the valid percentage using only those latest records. This way, your row-level and region-level totals will reflect only the most recent data per country. Here's a rough idea of how the logic works:
Please create a calculated column as belolw:
IsLatestRecord =
VAR CurrentDate = 'Table'[Date]
VAR Country = 'Table'[Country]
VAR MaxDate =
CALCULATE (
MAX ( 'Table'[Date] ),
ALLEXCEPT ( 'Table', 'Table'[Country] )
)
RETURN IF ( CurrentDate = MaxDate, 1, 0 )
Then create a measure as below:
ValidCustomer% (Latest Only) =
VAR LatestData =
FILTER (
'Table',
'Table'[IsLatestRecord] = 1
)
VAR TotalValid = SUMX ( LatestData, 'Table'[records_valid] )
VAR TotalCount = SUMX ( LatestData, 'Table'[records_count] )
RETURN DIVIDE ( TotalValid, TotalCount ) * 100
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Regards,
B Manikanteswara Reddy
Thank you very much Anonymous, the issue is resolved now.
I appreciate the effort you took to help me.
Cheers,
Karthick M