# Data Type Error Occurs When Calculating Based on Conditions for Each Group

**URL:** <https://community.exploratory.io/t/data-type-error-occurs-when-calculating-based-on-conditions-for-each-group/4136>\
**Category:** Issues\
**Created:** [January 14, 2026, 3:24pm UTC](https://community.exploratory.io/t/data-type-error-occurs-when-calculating-based-on-conditions-for-each-group/4136 "2026-01-14T15:24:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Takato\_Shiroto](https://community.exploratory.io/user_avatar/community.exploratory.io/takato_shiroto/32/749_2.png) [@Takato\_Shiroto](https://community.exploratory.io/u/Takato_Shiroto)\
**Post date:** [January 14, 2026, 3:24pm UTC](https://community.exploratory.io/t/data-type-error-occurs-when-calculating-based-on-conditions-for-each-group/4136/1 "2026-01-14T15:24:06Z")

</div>

For example, suppose you have executed “Group By” before performing “Calculate Based on Condition.”

 ![image](https://community.exploratory.io/uploads/default/original/2X/3/331ef405d24a50ff672b75320e0c25e8051c089e.png)

When you execute “Calculate Based on Condition” in this grouped state, the following error may occur:

```auto
Error in mutate(., across(c(Value, Value1), .names = "{col}_lag_pct", : 
  ℹ In argument: `across(...)`.
Caused by error:
! `Value_lag_pct` must return compatible vectors across groups.
ℹ Result of type <double> for group A: `ID = "A"`.
ℹ Result of type <character> for group B: `ID = "B"`.

```

 ![image](https://community.exploratory.io/uploads/default/original/2X/c/cccd10ccf95f4b8d66dae33a49fe19600ffc60ac.png)

This error occurs when grouping and automatic data type detection are used together, causing some groups to have numeric data types while others have character data types.

 ![image](https://community.exploratory.io/uploads/default/original/2X/0/0326ad7edbef23b5c061dfc3d09ffe457636f4a1.jpeg)

Therefore, you can avoid this error by explicitly specifying the data type as “Character” before execution.

 ![image](https://community.exploratory.io/uploads/default/original/2X/2/29bc8371fa1637f73c389800e5310fae811afcda.jpeg)
