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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Issue with count and Total

Having an issue with my Count and totals 

Issue #1.

Trying to take the count of the Status with "Ready" of orders by date. The fact table contains the Order # and the date and status. 

I am using Distinct count since the fact will have order and line details also. 

Status Count = Calculate(DISTINCTCOUNT('Fact'[Status]),'Fact'[Status] = "Ready")
My expected result for 02/16 is a count of 2. But my measure is showing only 1. 
 
Issue #2.
The totals on the weight is off. The weight information for the order is only at the Orders header table. Fact includes both header & item level details. I am trying to bring the total into the visual, but they seem off when i do sum to get the total line. 
 
Order NoTotal PriceSum of FreightWeight
10003$77,5004510878
10005$110,3754510878
    
Total187,8754510878
 
 Expected result is 
Order NoTotal PriceSum of FreightWeight
10003$77,500452250
10005$110,375451300
    
Total187,875903550

 

Attaching my pbix. 

https://drive.google.com/file/d/1FvG6KSw16V0rmq_N6Mf-DRHr1rNI0KRJ/view?usp=sharing

 

 

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@Anonymous  See the attached pbix below my signature and explanation below for what I have done. 

 

Issue 1

You are doing a distinctcount on status, and filtering for 1 status ="Ready", so the result will always be 1 or zero. 

Try doing a DISTINCTCOUNT(Fact[OrderNo]) instead, or if you have a Order table you could COUNTROWS on that table, but in that case your filter might get more complex. So the simple solution is: 

 

Status Count = Calculate(DISTINCTCOUNT('Fact'[Order No]),'Fact'[Status] = "Ready")

 

Issue 2

You need relationships between Orders and Fact table. I have not related Orders Detail as it looks like your fact table has all that info so Orders Detail is redundant? 

AllisonKennedy_0-1615086504461.png

 

See if these three posts help with relating your data: https://excelwithallison.blogspot.com/2020/08/its-complicated-relationships-in-power_92.html

 

Once you have the tables related properly, you can use a measure such as: 

 

Total Weight = SUMX(FILTER(Orders, CALCULATE(SUM('Fact'[Total Price])) > 0),Orders[Weight])
 
to calculate Total Weight. 
 
Freight is simpler since you need a value for every row of Fact table: 
 
Total Freight = SUMX('Fact', RELATED('Shipper charge'[Freight]))
 
 
 
 

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

1 REPLY 1
AllisonKennedy
Super User
Super User

@Anonymous  See the attached pbix below my signature and explanation below for what I have done. 

 

Issue 1

You are doing a distinctcount on status, and filtering for 1 status ="Ready", so the result will always be 1 or zero. 

Try doing a DISTINCTCOUNT(Fact[OrderNo]) instead, or if you have a Order table you could COUNTROWS on that table, but in that case your filter might get more complex. So the simple solution is: 

 

Status Count = Calculate(DISTINCTCOUNT('Fact'[Order No]),'Fact'[Status] = "Ready")

 

Issue 2

You need relationships between Orders and Fact table. I have not related Orders Detail as it looks like your fact table has all that info so Orders Detail is redundant? 

AllisonKennedy_0-1615086504461.png

 

See if these three posts help with relating your data: https://excelwithallison.blogspot.com/2020/08/its-complicated-relationships-in-power_92.html

 

Once you have the tables related properly, you can use a measure such as: 

 

Total Weight = SUMX(FILTER(Orders, CALCULATE(SUM('Fact'[Total Price])) > 0),Orders[Weight])
 
to calculate Total Weight. 
 
Freight is simpler since you need a value for every row of Fact table: 
 
Total Freight = SUMX('Fact', RELATED('Shipper charge'[Freight]))
 
 
 
 

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.