Forum Discussion

RicardoLeivaG's avatar
5 years ago
Solved

Problemas con GROUPBY

Hola Comunidad, 

 

tengo el siguiente problema con un groupBy 

Codigo:

compras =
GROUPBY(ih_hist20062020,
                 ih_hist20062020[Fecha factura]. Año],
                 ih_hist20062020[Nombre],
                 "Total",SUMX(CURRENTGROUP(),ih_hist20062020[Monto Neto]),
                 "Cantidad de Invoice",COUNTX(CURRENTGROUP(), COUNTROWS(DISTINCT(ih_hist20062020[Invoice]
))))
 
La suma del total, cuadra pero al buscar el numero de Invoice, el cual se repite, me devuelve un numero de 1456 cuando deberia ser 1220
 
alguno idea o estopy haciendo mal la agrupacion???
  • Have you tried the same with SUMMARIZE instead to simplify it

     

    Purchases =
    ADDCOLUMNS (
        SUMMARIZE (
            ih_hist20062020,
            ih_hist20062020[Invoice Date].[Year],
            ih_hist20062020[Number]
        ),
        "Total",
            CALCULATE (
                SUM ( ih_hist20062020[Net Amount] )
            ),
        "Cantidad de Invoice",
            CALCULATE (
                DISTINCTCOUNT ( ih_hist20062020[Invoice] )
            )
    )

     
    Pat

2 Replies

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    Have you tried the same with SUMMARIZE instead to simplify it

     

    Purchases =
    ADDCOLUMNS (
        SUMMARIZE (
            ih_hist20062020,
            ih_hist20062020[Invoice Date].[Year],
            ih_hist20062020[Number]
        ),
        "Total",
            CALCULATE (
                SUM ( ih_hist20062020[Net Amount] )
            ),
        "Cantidad de Invoice",
            CALCULATE (
                DISTINCTCOUNT ( ih_hist20062020[Invoice] )
            )
    )

     
    Pat