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
Dunner2020
Post Prodigy
Post Prodigy

Count of records with two types of values

Hi there,

 

I got a data which contains the registration number and authorisation type of the registration number. I want to calculate the no of registration number that are holding two types of authorisation types i.e. LAT and PROV or LAT and Tōmua/Prov. I created a measure as follow:

 

2 types =
SUMX(Authorisation,
Var _auth = CALCULATE(MAX(Authorisation[Authorisation_Type__c]))
RETURN
IF(Authorisation[Authorisation_Type__c] = "LAT" && (Authorisation[Authorisation_Type__c] = "PROV" || Authorisation[Authorisation_Type__c] = "Tōmua/Prov"),1,0))
 
However, the above measure returns 0 which is not the case. Could anyone help me in fixing the issue?
 
Data here

 

1 ACCEPTED SOLUTION

I'm not sure I'm interpreting your question correctly, but maybe this will be closer to what you're after:

Two types = 
SUMX (
    VALUES ( Authorisation[Individual__r.Registration_Number__c] ),
    IF (
        CALCULATE (
            DISTINCTCOUNT ( Authorisation[Authorisation_Type__c] ),
            Authorisation[Authorisation_Type__c] IN { "LAT", "PROV", "Tōmua/Prov" }
        ) = 2,
        1,
        0
    )
)

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Since you have not described what you want, i am just making a guess of desired result.  Try this measure

2 types try = SUMX(VALUES(Sheet1[Registration_Number__c]),
                   
                    VAR _auth = CALCULATE(MAX(Sheet1[Authorisation_Type__c]))
                  
                    RETURN IF(_auth="LAT" || (_auth = "PROV" || _auth = "Tōmua/Prov") ,1,0))

The result i get is 26,566


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
AlexisOlson
Super User
Super User

This is returning 0 because the single-value-variable _auth cannot logically equal "LAT" and any other value at the same time.

 

Also, looking at your data, each Registration_Number__c occurs only in a single row, so I don't see how it can be associated with more than one authorization type.

@AlexisOlson , Sorry I updated the data sample and also updated the measure but still getting the same result i.e. 0

I'm not sure I'm interpreting your question correctly, but maybe this will be closer to what you're after:

Two types = 
SUMX (
    VALUES ( Authorisation[Individual__r.Registration_Number__c] ),
    IF (
        CALCULATE (
            DISTINCTCOUNT ( Authorisation[Authorisation_Type__c] ),
            Authorisation[Authorisation_Type__c] IN { "LAT", "PROV", "Tōmua/Prov" }
        ) = 2,
        1,
        0
    )
)

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.