cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Frequent Visitor

## Problems how many order by category

I have some problems with how many Order by category

2 ACCEPTED SOLUTIONS
Memorable Member

hi, @mmunozi1984

i think there are some confusion

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

so

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.

Memorable Member

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

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

I realized my mistake, your solution is correct.

Memorable Member

hi, @mmunozi1984

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

Frequent Visitor

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.

My model data

Memorable Member

hi, @mmunozi1984

i think there are some confusion

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

so

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.

Memorable Member

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

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.

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors