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
Mikey575
Frequent Visitor

Unique Distinct Count of Policy Numbers dependent on Other Column Criteria

Hi

I am fairly new to Power BI and DAX. I am currently trying to move a report from Qlikview to Power BI and one of the formulas I need to replicate uses qlikview functions P() & E() that dont seem to be available in Power BI but i am sure DAX could replicate in some way. I have spent some time looking on this forum but any answers that seem to tackle the issue dont work when I apply them.

 

In the example below i have a list of policy numbers and products and i only want to count the products where they exist on their own. E.g. I want the count of policy numbers for the Product called ISA where the corresponding policy number doesnt have another Product attached to it. The number of ISAs in the list below is 4 but the result i want based on the criteria above is 2.

 

If we were to replicate this for the Product SIPP then the number of SIPPs in the list is 5 but the result i want is 3.

If again we were to replicate this for the Product Cash then the number of Cash in the list is 3 but the result i want is 1.

 

I have colour coded what needs to be counted with the results in the same colour 

 

Does anyone one have a DAX formula that would do this?

 

Mikey575_1-1697535524088.png

 

 

1 ACCEPTED SOLUTION
DimaMD
Solution Sage
Solution Sage

Hi @Mikey575  try it measure

Product_count = 
VAR coun = 
ADDCOLUMNS(
    'table', "counta", 
    CALCULATE( 
        COUNT([Policy Number]), 
        FILTER( ALL('table'), [Policy Number] = EARLIER([Policy Number])
        )
    )
)
VAR result = CALCULATE( COUNT('table'[Product]), FILTER( coun, [counta] = 1))
return
result

DimaMD_0-1697546901795.png

 


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

View solution in original post

5 REPLIES 5
Mikey575
Frequent Visitor

Thanks @DimaMD how would I code it so I isolate just 1 product, say ISA? 

@Mikey575  Hi, Specify your question, what exactly do you want to see?


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

Hi DimaMD

 

So your solution brings back the correct result. However i would like to modify it so it only brings back the Count for the Product ISA. See Below:

 

Mikey575_0-1697617228973.png

 

@Mikey575 You have two options to add a slicer with products or to add filtering by product

DimaMD_0-1697631468284.png

DimaMD_1-1697631526522.png

In my opinion, it is better to add a slicer to the report and you will be able to see the quantity for any product

 


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com
DimaMD
Solution Sage
Solution Sage

Hi @Mikey575  try it measure

Product_count = 
VAR coun = 
ADDCOLUMNS(
    'table', "counta", 
    CALCULATE( 
        COUNT([Policy Number]), 
        FILTER( ALL('table'), [Policy Number] = EARLIER([Policy Number])
        )
    )
)
VAR result = CALCULATE( COUNT('table'[Product]), FILTER( coun, [counta] = 1))
return
result

DimaMD_0-1697546901795.png

 


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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