Forum Discussion

mmunozi1984's avatar
mmunozi1984
Frequent Visitor
3 years ago
Solved

Problems how many order by category

I have some problems with how many Order by category

  • Dangar332's avatar
    Dangar332
    3 years ago

    hi, mmunozi1984 

    i think there are some confusion

    let's break your code and try to know what  output is 

    so

    ADDCOLUMNS(
        SUMMARIZE('Categorias',Categorias[NombreCategoria]),
        "pedidos",CALCULATE(COUNTROWS(RELATEDTABLE('Detalles de pedidos'))))
     
    give output like below (i am calculate new table )

     

    it give you a table which contain 8 rows (distinct value of NombreCategoria)

    and count of related rows from table Detalles de pedidos.

    these  same answer given by my formula

     

    in below code 

     COUNTROWS(
        FILTER(
           
            [Pedidos] > 0
        )
    )

     

    an you try to count rows of above table(in above image)

    which contain 8 distinct rows of NombreCategoria  (not rows present in table Detalles de pedidos)

    so it give 1 value in NombreCategoria   and total  8 (because 8 rows present in above table).

     

     

    you use   [Pedidos] > 0  but no value(count) below zero

    I hope you clear what i want to say

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. and don't forget to give kudos.

     

  • Hi, mmunozi1984 

    i hope you understand what i try to explain


    and now your desired output is below

     

    result =
    var a = CALCULATE(COUNTROWS(Pedidos),RELATEDTABLE('Detalles de pedidos'))
    return a
     

    download .pbix file HERE 

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. and don't forget to give kudos.

     

     

5 Replies

  • Dangar332's avatar
    Dangar332
    Icon for Resident Rockstar rankResident Rockstar

    hi, mmunozi1984 

    try below
    result = calculate(countrows('detalles de pedidos'), relatedtable('detalles de pedidos'))

      • Dangar332's avatar
        Dangar332
        Icon for Resident Rockstar rankResident Rockstar

        hi, mmunozi1984 

        i think there are some confusion

        let's break your code and try to know what  output is 

        so

        ADDCOLUMNS(
            SUMMARIZE('Categorias',Categorias[NombreCategoria]),
            "pedidos",CALCULATE(COUNTROWS(RELATEDTABLE('Detalles de pedidos'))))
         
        give output like below (i am calculate new table )

         

        it give you a table which contain 8 rows (distinct value of NombreCategoria)

        and count of related rows from table Detalles de pedidos.

        these  same answer given by my formula

         

        in below code 

         COUNTROWS(
            FILTER(
               
                [Pedidos] > 0
            )
        )

         

        an you try to count rows of above table(in above image)

        which contain 8 distinct rows of NombreCategoria  (not rows present in table Detalles de pedidos)

        so it give 1 value in NombreCategoria   and total  8 (because 8 rows present in above table).

         

         

        you use   [Pedidos] > 0  but no value(count) below zero

        I hope you clear what i want to say

         

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. and don't forget to give kudos.