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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
refint650
Helper III
Helper III

Unique Employee does set operator function works.?

Hello ALL

 

couldnt figure how to write this conditional expression  where filter unique employees when purchase flag ='N' and dont  count same employee  if he has flag "Y"

can write set operator calculation does it work

Var A = filter and count employe where purchase flag  ='Y'

Var B =filter and count employe where purchase flag  ='N'

return 

 

refint650_0-1645655697659.png

Ps

5 REPLIES 5
refint650
Helper III
Helper III

@Samarth_18 

Appreciate for response @Samarth_18 , In measure what will be return syntax..

 

 

@refint650 Its depend on what output you need 🙂

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Samarth_18
Community Champion
Community Champion

Hi @refint650 ,

 

Create a column like below:-

Y Flag =
IF (
    CALCULATE (
        COUNT ( 'Table'[EmployeeID] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[EmployeeID] = EARLIER ( 'Table'[EmployeeID] )
                && 'Table'[Purchase Flag] = "Y"
        )
    ) > 0,
    1,
    0
)

 

Now create a measure which you trying like below:-

Measure =
VAR A =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[EmployeeID] ),
        FILTER ( 'Table', 'Table'[Y Flag] = 1 )
    )
VAR B =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[EmployeeID] ),
        FILTER ( 'Table', 'Table'[Y Flag] = 0 )
    )

Return

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

EARLIER/EARLIEST refers to an earlier row context which doesn't exist. when doing calculated colum1 

-

'Table'[EmployeeID] = EARLIER ( 'Table'[EmployeeID] )

 

 

Hi @refint650 ,

 

Please try this measure. Since I don't know the result you want to return, here I wrote it as "Y_count - N_count". You can change the part of RETURN, or you can split this formula into two and return the counts of Y flag and N flag respectively.

 

Measure = 
VAR Y_tab =
    CALCULATETABLE ( VALUES ( 'Table'[EmployeeName] ), 'Table'[PurchaseFlag] = "Y" )
VAR Y_count =
    COUNTROWS ( Y_tab )
VAR N_count =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[EmployeeName] ),
        FILTER (
            EXCEPT ( VALUES ( 'Table'[EmployeeName] ), Y_tab ),
            MAX ( 'Table'[PurchaseFlag] ) = "N"
        )
    )
RETURN
    Y_count - N_count

vkkfmsft_0-1646030839874.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors