Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Foguete
Helper I
Helper I

COUNTAX, end of input reached

Hi,

 

I ma trying to use COUNTAX for the first time but I ma getting the following error:

The end of the input was reached 

 

The goal of this formula is to determine the turn (either "Diurno" or "Nocturno") for a given date and operator, based on the number of tasks assigned to that operator for that date.

Then, the formula uses the "IF" function to compare the count of tasks assigned to the operator for a given date, where the turn is "Diurno", to the count of tasks assigned to the operator for the same date, where the turn is "Nocturno Mañana" or "Nocturno Tarde".

If the count of tasks assigned for the "Diurno" turn is greater than the count of tasks assigned for the "Nocturno Mañana" or "Nocturno Tarde" turn, the formula returns "Diurno". Otherwise, it returns "Nocturno".

In summary, the formula calculates the number of tasks assigned to a specific operator for a given date, and based on this count, returns the turn (either "Diurno" or "Nocturno") for that operator on that date.

 

Does anyone has an idea of where the error can be from?

Turno =
VAR curFecha = TareasXOperariosXCias[Fecha real]
var curOperario = TareasXOperariosXCias[OPERARIO]
RETURN

IF(
    CALCULATE(
        COUNTAX(
            TareasXOperariosXCias,
            FILTER(
                TareasXOperariosXCias,
                curFecha = TareasXOperariosXCias[Fecha real]
                &&
                curOperario = TareasXOperariosXCias[OPERARIO]
                &&
                (TareasXOperariosXCias[TURNO_DETALLADO] = "Diurno")
            )
        )
    )
    >
    CALCULATE(
        COUNTAX(
            TareasXOperariosXCias,
            FILTER(
                TareasXOperariosXCias,
                curFecha = TareasXOperariosXCias[Fecha real]
                &&
                curOperario = TareasXOperariosXCias[OPERARIO]
                &&
                TareasXOperariosXCias[TURNO_DETALLADO] = "Nocturno Mañana" || TareasXOperariosXCias[TURNO_DETALLADO] = "Nocturno Tarde"
            )
        )
    ),
    "Diurno",
    "Nocturno"
)

 

1 ACCEPTED SOLUTION

Hi ! 
Unfortunately it did not work but I find a solution that I post below in case someone might need it. Thank you !

Instead of COUNTAX and VAR I used EARLIER():

COUNTROWS(
FILTER(
TareasXOperariosXCias,
EARLIER(TareasXOperariosXCias[UNIDAD_TEMPORAL])=TareasXOperariosXCias[UNIDAD_TEMPORAL]
&&
EARLIER(TareasXOperariosXCias[OPERARIO])=TareasXOperariosXCias[OPERARIO]
&&
EARLIER(TareasXOperariosXCias[Actividad])=TareasXOperariosXCias[Actividad]
&&
TareasXOperariosXCias[TURNO_DETALLADO] = "Nocturno Mañana"
)
)

View solution in original post

2 REPLIES 2
MasterSonic
Helper IV
Helper IV

Maybe parenthesis almost in the end after 

 Nocturno Tarde")

 

Turno =

VAR curFecha = TareasXOperariosXCias[Fecha real]

var curOperario = TareasXOperariosXCias[OPERARIO]

RETURN

 

IF(

    CALCULATE(

        COUNTAX(

            TareasXOperariosXCias,

            FILTER(

                TareasXOperariosXCias,

                curFecha = TareasXOperariosXCias[Fecha real]

                &&

                curOperario = TareasXOperariosXCias[OPERARIO]

                &&

                (TareasXOperariosXCias[TURNO_DETALLADO] = "Diurno")

            )

        )

    )

    >

    CALCULATE(

        COUNTAX(

            TareasXOperariosXCias,

            FILTER(

                TareasXOperariosXCias,

                curFecha = TareasXOperariosXCias[Fecha real]

                &&

                curOperario = TareasXOperariosXCias[OPERARIO]

                &&

                (TareasXOperariosXCias[TURNO_DETALLADO] = "Nocturno Mañana" || TareasXOperariosXCias[TURNO_DETALLADO] = "Nocturno Tarde")

            )

        )

),

    "Diurno",

    "Nocturno"

)

 

Hi ! 
Unfortunately it did not work but I find a solution that I post below in case someone might need it. Thank you !

Instead of COUNTAX and VAR I used EARLIER():

COUNTROWS(
FILTER(
TareasXOperariosXCias,
EARLIER(TareasXOperariosXCias[UNIDAD_TEMPORAL])=TareasXOperariosXCias[UNIDAD_TEMPORAL]
&&
EARLIER(TareasXOperariosXCias[OPERARIO])=TareasXOperariosXCias[OPERARIO]
&&
EARLIER(TareasXOperariosXCias[Actividad])=TareasXOperariosXCias[Actividad]
&&
TareasXOperariosXCias[TURNO_DETALLADO] = "Nocturno Mañana"
)
)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.