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
mmunozi1984
Frequent Visitor

Problems how many order by category

mmunozi1984_0-1697785972357.png

I have some problems with how many Order by category

2 ACCEPTED SOLUTIONS

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 )
Dangar332_0-1697830812180.png

 

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).

Dangar332_1-1697831501491.png

 

 

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.

 

View solution in original post

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
 

Dangar332_0-1697832526307.png

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.

 

 

View solution in original post

5 REPLIES 5
mmunozi1984
Frequent Visitor

I realized my mistake, your solution is correct.

 
Dangar332
Super User
Super User

hi, @mmunozi1984 

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

I appreciate your efforts to assist me. However, it seems that it’s not functioning as expected. I’m aware that the total order amounts to 830. Therefore, the value of each category should be less than this figure. I show that the delivered measure turns out . I appreciate any help in advance.

 

 

mmunozi1984_0-1697829486103.png

 

 My model data

 

Captura de pantalla 2023-10-20 155722.png

 

https://drive.google.com/file/d/1tnZvCo8tAebXt7Zqgg0oPL7oLbGTMbnS/view?usp=share_link 

 

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 )
Dangar332_0-1697830812180.png

 

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).

Dangar332_1-1697831501491.png

 

 

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
 

Dangar332_0-1697832526307.png

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.

 

 

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.