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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
jwin2424
Resolver I
Resolver I

Distinct Count if ALL rows have the exact same value

Hello. 

 

I am trying to determine how many distict orders have ONLY the data type "potential."

 

Here is the output count I am needing:

 

Distinct Count with at least one actualDiscint Count with no actuals
33

 

 

Here is the data

 

Order IDData Type
101potential
101potential
101potential
101potential
101potential
101potential
101potential
543potential
543potential
543potential
543actual
543actual
543potential
543potential
543potential
543potential
754potential
754potential
754potential
246actual
246actual
246actual
246potential
246actual
269actual
269actual
269actual
269actual
269actual
231potential
231potential
231potential
231potential

 

I am able to get a distinct count of orders with the word "actual" in it, but if I filter by "potential", you will get orders that have both "potential" and "actual:". Thought that is fine for my model with the "actual", I need to know how many orders do not contain the word "actual" on any of the lines.

 

Thanks!

1 ACCEPTED SOLUTION
TheoC
Super User
Super User

Hi @jwin2424 

 

You can use the following two measures:

 

DCount Actual = 

VAR _1 = COUNTROWS ( FILTER ( DISTINCT ( Table[Order ID] ) , [Actual] > 0 ) )

RETURN

_1

 

DCount No Actual = 

VAR _1 = COUNTROWS ( FILTER ( DISTINCT ( Table[Order ID] ) , [Actual] = 0 ) )

RETURN

_1

Output will be as per below:

TheoC_0-1646168955269.png

 

Hope this helps!

Theo 🙂

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

View solution in original post

5 REPLIES 5
jwin2424
Resolver I
Resolver I

Thank you for the quick reply! That did get me halfway there. However, when I add the data type into the rows so I see which orders only have potential, it is still calculating rows that have actual. The TOTALS work, but not at the row level

jwin2424_0-1646169418478.png

 

Hi @jwin2424 

 

In your post, you asked for the distinct counts based on requirements and provided theoutputs you require.  If there are other requirements you need, please add these to the original post to ensure that the solutions are provided in the most resourceful way possible.

 

In terms of what you are after, Matrix visuals do not work as you have presented.  Your matrix visual has underlying rows (hence the +) and Power BI is calculating those records too.  Basically, Power BI is doing what you are asking it to do in this instance.

 

If you remove the underlying records, and bring the measures into your matrix at the Row Level, turn on the Switch Values to Rows option, you will get 3 and 3.

 

TheoC_0-1646169724031.png

TheoC_1-1646169766627.png

 

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

I see. I removed the actual/potential rows and being able to switch to rows not columns helped. Thank you. This solution worked

@jwin2424 no worries mate.  Just a heads up, and as silly as this sounds, Matrix and Table visuals work very differently in Power BI.  It is one of the more complex areas in Power BI because what would normally be considered "logical" in one, is not necessarily the case for the other.  Nonetheless, they each serve a solid purpose but just be conscious of the nuances in each (especially with Matrix visual and Subtotals / Totals).

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

TheoC
Super User
Super User

Hi @jwin2424 

 

You can use the following two measures:

 

DCount Actual = 

VAR _1 = COUNTROWS ( FILTER ( DISTINCT ( Table[Order ID] ) , [Actual] > 0 ) )

RETURN

_1

 

DCount No Actual = 

VAR _1 = COUNTROWS ( FILTER ( DISTINCT ( Table[Order ID] ) , [Actual] = 0 ) )

RETURN

_1

Output will be as per below:

TheoC_0-1646168955269.png

 

Hope this helps!

Theo 🙂

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.