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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.