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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
AkashDesai
New Member

Condition Help

I have a table shown below. What I want to do is sum the "Piece Count" column values only if values in "Tag No" column are equal.
Afterwards, I want to distinct count number of  Tag No (Rows) where Std Pc Count and Piece Count are not equal. Please help.

AkashDesai_0-1728225988932.png

 

1 ACCEPTED SOLUTION
dharmendars007
Solution Sage
Solution Sage

Hello @AkashDesai , 

 

You can create a calculated column to sum the "Piece Count" where the "Tag No" is the same.

 

TotalPieceCountByTagNo =
CALCULATE(
SUM(TableName[Piece Count]),ALLEXCEPT(TableName, TableName[Tag No]))

 

Next, you can create a measure to count distinct "Tag No" where the total "Piece Count" differs from the "Std Pc Count".

 

This measure filters the rows where the total piece count for a "Tag No" does not match the "Std Pc Count" and then performs a distinct count of those "Tag No" values

 

DistinctCountOfTagNo =
CALCULATE(
DISTINCTCOUNT(TableName[Tag No]),
FILTER(
TableName,TableName[TotalPieceCountByTagNo] <> TableName[Std Pc Count]))

 

If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes 👍 are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

View solution in original post

3 REPLIES 3
dharmendars007
Solution Sage
Solution Sage

Hello @AkashDesai , 

 

You can create a calculated column to sum the "Piece Count" where the "Tag No" is the same.

 

TotalPieceCountByTagNo =
CALCULATE(
SUM(TableName[Piece Count]),ALLEXCEPT(TableName, TableName[Tag No]))

 

Next, you can create a measure to count distinct "Tag No" where the total "Piece Count" differs from the "Std Pc Count".

 

This measure filters the rows where the total piece count for a "Tag No" does not match the "Std Pc Count" and then performs a distinct count of those "Tag No" values

 

DistinctCountOfTagNo =
CALCULATE(
DISTINCTCOUNT(TableName[Tag No]),
FILTER(
TableName,TableName[TotalPieceCountByTagNo] <> TableName[Std Pc Count]))

 

If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes 👍 are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

Dharmendra, thanks for your help. Your answer helped me to get better at syntax and solved my problem partially. Although I have one more catch which I came across just now. See the following example where I have same tag no being duplicated twice. So, before I use your first measure, I need to get rid of this duplication in such a way that I still count it once. How will that be possible? In this case, piece count is matching with std pc count so it's a right entry but need to consider it only once.

AkashDesai_0-1728249313133.png

 

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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