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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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