Skip to main content
cancel
Showing results for 
Search instead 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

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
Memorable Member
Memorable Member

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
Fabric Community Conference

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.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

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