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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
jlayala
Frequent Visitor

Countries or countx returning blank total but row by row ok.

Hi everyone, hope can someone help me.

I have a table that one measure ("usuario nuevo registrados") do not gives me the total. All measures use the same table. 

 

jlayala_1-1656712316764.png    

the card show blank as total is in the table.

jlayala_2-1656712429069.png

 

 

Usuario Nuevo Registrados = 
VAR fecha =
    SELECTEDVALUE ( 'paynom usuarios'[created_at] )
VAR Fecha_min =
    EOMONTH ( fecha, -1 )
VAR Fecha_max =
    EOMONTH ( fecha, 0 )
VAR tabla_filtro =
    FILTER (
        ADDCOLUMNS (
            'paynom usuarios',
            "@Fecha_min", Fecha_min,
            "@Fecha_max", Fecha_max
        ),
        fecha > Fecha_min
            && fecha <= Fecha_max
            && 'paynom usuarios'[rol_id] = 3
            && 'paynom usuarios'[registrado] = TRUE()
    )
VAR CONTEO_USUARIOS_NUEVOS = 
    COUNTX ( 
        tabla_filtro,
        'paynom usuarios'[username] 
    )
RETURN
COUNTROWS( tabla_filtro)
the other measure is more simple 
Usuario Registrado = calculate ( 
    COUNTROWS( 'paynom usuarios') ,
        'paynom usuarios'[registrado] = TRUE() ,
        'paynom roles'[name] = "employee"
)

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

 Hi @jlayala 
Please try

Usuario Nuevo Registrados =
SUMX (
    TableName,
    CALCULATE (
        VAR fecha =
            SELECTEDVALUE ( 'paynom usuarios'[created_at] )
        VAR Fecha_min =
            EOMONTH ( fecha, -1 )
        VAR Fecha_max =
            EOMONTH ( fecha, 0 )
        VAR tabla_filtro =
            FILTER (
                ADDCOLUMNS (
                    'paynom usuarios',
                    "@Fecha_min", Fecha_min,
                    "@Fecha_max", Fecha_max
                ),
                fecha > Fecha_min
                    && fecha <= Fecha_max
                    && 'paynom usuarios'[rol_id] = 3
                    && 'paynom usuarios'[registrado] = TRUE ()
            )
        VAR CONTEO_USUARIOS_NUEVOS =
            COUNTX ( tabla_filtro, 'paynom usuarios'[username] )
        RETURN
            COUNTROWS ( tabla_filtro )
    )
)

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

 Hi @jlayala 
Please try

Usuario Nuevo Registrados =
SUMX (
    TableName,
    CALCULATE (
        VAR fecha =
            SELECTEDVALUE ( 'paynom usuarios'[created_at] )
        VAR Fecha_min =
            EOMONTH ( fecha, -1 )
        VAR Fecha_max =
            EOMONTH ( fecha, 0 )
        VAR tabla_filtro =
            FILTER (
                ADDCOLUMNS (
                    'paynom usuarios',
                    "@Fecha_min", Fecha_min,
                    "@Fecha_max", Fecha_max
                ),
                fecha > Fecha_min
                    && fecha <= Fecha_max
                    && 'paynom usuarios'[rol_id] = 3
                    && 'paynom usuarios'[registrado] = TRUE ()
            )
        VAR CONTEO_USUARIOS_NUEVOS =
            COUNTX ( tabla_filtro, 'paynom usuarios'[username] )
        RETURN
            COUNTROWS ( tabla_filtro )
    )
)

It works! Thanks.  What would be the reason ? is it the aggregate function? 

Hi @jlayala 

the reason is SELECTEDVALUE which returns blank in case of multiple values found. Therefore, totals will allways be blank. SUMX restores the lost value by summing the visible values snd aggregate them in the total cell

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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