Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
stino123
Helper II
Helper II

Sumifs in power bi

Hey,

 

I have I believe a pretty simple request, I unfortunately cannot seem to figure it out. For the below table created from my dataset set I want to count for each unique order nr determine how many items were purchased total. However everytime I do a formula where Line qty is greater than 1 it returns orders which have a line qty of the value of 2 rather than the sum. 

 

Example: order 10000 has 3 unique items with a line quantity of 1 for a sum total of 3. while another order has 1 unique item with a line qty of 2 for a sum total of 2. The below formula keep returning the latter condition and not the former.

 

Sum if line quantity = CALCULATE(SUM(FACT_Orders[Line QTY]),DISTINCT(FACT_Orders[Order Nr]))

 

stino123_0-1643357280561.png

 

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @stino123 ,

 

When there are other groupings in the table, it will have an effect on the results of the grouping statistics. You can create a dummy table and then count the total number of rows with orders greater than 1.

vhenrykmstf_0-1643858439238.png

t_ = SUMMARIZE('Table','Table'[Order],'Table'[Col_order2])
Measure = CALCULATE(COUNTROWS(t_),t_[Col_order2]>1)

vhenrykmstf_1-1643858504624.png

If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your feedback.


Best Regards,
Henry


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-henryk-mstf
Community Support
Community Support

Hi @stino123 ,

 

When there are other groupings in the table, it will have an effect on the results of the grouping statistics. You can create a dummy table and then count the total number of rows with orders greater than 1.

vhenrykmstf_0-1643858439238.png

t_ = SUMMARIZE('Table','Table'[Order],'Table'[Col_order2])
Measure = CALCULATE(COUNTROWS(t_),t_[Col_order2]>1)

vhenrykmstf_1-1643858504624.png

If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your feedback.


Best Regards,
Henry


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

stino123
Helper II
Helper II

Thanks for the quick reply. Not quiet, now I need to count how many distinct order number have a sum line quantity greater than two. 

@stino123 

 

Sum if line quantity =
CALCULATE ( DISTINCTCOUNT ( FACT_Orders[Order Nr] ), FACT_Orders[Line QTY] > 2 )

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hey @Fowmy, this formula shows a condition where line quantity is greater than two. What Is needed if the amount of unique lines for a unique order is greater than two. as you see below in the raw data this order is greater than 2 however the number of lines is 1

 

stino123_1-1643360195704.png

 

Fowmy
Super User
Super User

@stino123 

Your order numbers are already grouped so you can use a simple measure. Maybe I got it wrong. 


Sum if line quantity  = SUM(FACT_Orders[Line QTY])

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.