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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Count of unique filtered by a variable

Hello all, 

 

I have been trying to do a user count, so I can use that number and divide it by total work. My goal is to have an average per selected group. The Measure 'Variable" is giving me the correct total user amount.

the formula for variable:

VARIABLE = 

var Totaluser = [(CF count - Preparer)]+[(CF count - Reviewer)]+[(Recon count - Preparer)]+[(Recon count - Reviewer)]+[(PortCo count - Preparer)]+[(PortCo count - Reviewer)]

var TotalSUM = 
IF(Totaluser=BLANK(),BLANK(),
CALCULATE(count(CF_NAV_Preparer[Operation Type]),ALLSELECTED(CF_NAV_Preparer),
CF_NAV_Preparer[Operation Type]="Cash Flow"||
CF_NAV_Preparer[Operation Type]="Stock Sale"||
CF_NAV_Preparer[Operation Type]="Stock Distribution")
+
CALCULATE(count(CF_NAV_Preparer[Recon Entered By - 2]),ALLSELECTED(CF_NAV_Preparer),
CF_NAV_Preparer[Operation Type]="Valuation")
+
CALCULATE(count(CF_NAV_Reviewer [Operation Type]),ALLSELECTED(CF_NAV_Reviewer),
CF_NAV_Reviewer[Operation Type]="Cash Flow"||
CF_NAV_Reviewer[Operation Type]="Stock Sale"||
CF_NAV_Reviewer[Operation Type]="Stock Distribution")
+
CALCULATE(count(CF_NAV_Reviewer[Recon Entered By - 2]),ALLSELECTED(CF_NAV_Reviewer),
CF_NAV_Reviewer[Operation Type]="Valuation")
+
CALCULATE(count(PortCo_Preparer[PortCo Entered By]),ALLSELECTED(PortCo_Preparer))
+
CALCULATE(count(PortCo_Reviewer [PortCo Reviewed By]),ALLSELECTED(PortCo_Reviewer)))

return 
TotalSUM


Capture.JPG

The following formula "Test" is intended to give me the number of users with "variable" not blank ideally the number will be 3 for the first 3 rows but it is giving me 1s for the first 3 and then a total of 10. 

test = 

var Totaluser = [(CF count - Preparer)]+[(CF count - Reviewer)]+[(Recon count - Preparer)]+[(Recon count - Reviewer)]+[(PortCo count - Preparer)]+[(PortCo count - Reviewer)]

var TotalSUM = 
IF(Totaluser=BLANK(),BLANK(),
CALCULATE(count(CF_NAV_Preparer[Operation Type]),ALLSELECTED(CF_NAV_Preparer),
CF_NAV_Preparer[Operation Type]="Cash Flow"||
CF_NAV_Preparer[Operation Type]="Stock Sale"||
CF_NAV_Preparer[Operation Type]="Stock Distribution")
+
CALCULATE(count(CF_NAV_Preparer[Recon Entered By - 2]),ALLSELECTED(CF_NAV_Preparer),
CF_NAV_Preparer[Operation Type]="Valuation")
+
CALCULATE(count(CF_NAV_Reviewer [Operation Type]),ALLSELECTED(CF_NAV_Reviewer),
CF_NAV_Reviewer[Operation Type]="Cash Flow"||
CF_NAV_Reviewer[Operation Type]="Stock Sale"||
CF_NAV_Reviewer[Operation Type]="Stock Distribution")
+
CALCULATE(count(CF_NAV_Reviewer[Recon Entered By - 2]),ALLSELECTED(CF_NAV_Reviewer),
CF_NAV_Reviewer[Operation Type]="Valuation")
+
CALCULATE(count(PortCo_Preparer[PortCo Entered By]),ALLSELECTED(PortCo_Preparer))
+
CALCULATE(count(PortCo_Reviewer [PortCo Reviewed By]),ALLSELECTED(PortCo_Reviewer)))

var usersss= CALCULATE(IF(TotalSUM>0,COUNTX(Users,[Username])))


var Totalcount2= if(Totaluser>0,TotalSUM,BLANK())
return 
 usersss

 

So ideally I want to be able to divide 192/3

 

Thanks for all your help!

 

 

1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can try to use the following measure to meet your requirement:

 

test =
SUMX (
    DISTINCT ( 'Users'[Username] ),
    VAR Totaluser =
        CALCULATE (
            [(CF count - Preparer)] + [(CF count - Reviewer)] + [(Recon count - Preparer)] + [(Recon count - Reviewer)] + [(PortCo count - Preparer)] + [(PortCo count - Reviewer)]
        )
    VAR TotalSUM =
        CALCULATE (
            IF (
                Totaluser
                    = BLANK (),
                BLANK (),
                CALCULATE (
                    COUNT ( CF_NAV_Preparer[Operation Type] ),
                    ALLSELECTED ( CF_NAV_Preparer ),
                    CF_NAV_Preparer[Operation Type] = "Cash Flow"
                        || CF_NAV_Preparer[Operation Type] = "Stock Sale"
                        || CF_NAV_Preparer[Operation Type] = "Stock Distribution"
                )
                    + CALCULATE (
                        COUNT ( CF_NAV_Preparer[Recon Entered By - 2] ),
                        ALLSELECTED ( CF_NAV_Preparer ),
                        CF_NAV_Preparer[Operation Type] = "Valuation"
                    )
                    + CALCULATE (
                        COUNT ( CF_NAV_Reviewer[Operation Type] ),
                        ALLSELECTED ( CF_NAV_Reviewer ),
                        CF_NAV_Reviewer[Operation Type] = "Cash Flow"
                            || CF_NAV_Reviewer[Operation Type] = "Stock Sale"
                            || CF_NAV_Reviewer[Operation Type] = "Stock Distribution"
                    )
                    + CALCULATE (
                        COUNT ( CF_NAV_Reviewer[Recon Entered By - 2] ),
                        ALLSELECTED ( CF_NAV_Reviewer ),
                        CF_NAV_Reviewer[Operation Type] = "Valuation"
                    )
                    + CALCULATE (
                        COUNT ( PortCo_Preparer[PortCo Entered By] ),
                        ALLSELECTED ( PortCo_Preparer )
                    )
                    + CALCULATE (
                        COUNT ( PortCo_Reviewer[PortCo Reviewed By] ),
                        ALLSELECTED ( PortCo_Reviewer )
                    )
            )
        )
    RETURN
        IF (
            TotalSUM > 0,
            1,
            0
        )
)

 


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can try to use the following measure to meet your requirement:

 

test =
SUMX (
    DISTINCT ( 'Users'[Username] ),
    VAR Totaluser =
        CALCULATE (
            [(CF count - Preparer)] + [(CF count - Reviewer)] + [(Recon count - Preparer)] + [(Recon count - Reviewer)] + [(PortCo count - Preparer)] + [(PortCo count - Reviewer)]
        )
    VAR TotalSUM =
        CALCULATE (
            IF (
                Totaluser
                    = BLANK (),
                BLANK (),
                CALCULATE (
                    COUNT ( CF_NAV_Preparer[Operation Type] ),
                    ALLSELECTED ( CF_NAV_Preparer ),
                    CF_NAV_Preparer[Operation Type] = "Cash Flow"
                        || CF_NAV_Preparer[Operation Type] = "Stock Sale"
                        || CF_NAV_Preparer[Operation Type] = "Stock Distribution"
                )
                    + CALCULATE (
                        COUNT ( CF_NAV_Preparer[Recon Entered By - 2] ),
                        ALLSELECTED ( CF_NAV_Preparer ),
                        CF_NAV_Preparer[Operation Type] = "Valuation"
                    )
                    + CALCULATE (
                        COUNT ( CF_NAV_Reviewer[Operation Type] ),
                        ALLSELECTED ( CF_NAV_Reviewer ),
                        CF_NAV_Reviewer[Operation Type] = "Cash Flow"
                            || CF_NAV_Reviewer[Operation Type] = "Stock Sale"
                            || CF_NAV_Reviewer[Operation Type] = "Stock Distribution"
                    )
                    + CALCULATE (
                        COUNT ( CF_NAV_Reviewer[Recon Entered By - 2] ),
                        ALLSELECTED ( CF_NAV_Reviewer ),
                        CF_NAV_Reviewer[Operation Type] = "Valuation"
                    )
                    + CALCULATE (
                        COUNT ( PortCo_Preparer[PortCo Entered By] ),
                        ALLSELECTED ( PortCo_Preparer )
                    )
                    + CALCULATE (
                        COUNT ( PortCo_Reviewer[PortCo Reviewed By] ),
                        ALLSELECTED ( PortCo_Reviewer )
                    )
            )
        )
    RETURN
        IF (
            TotalSUM > 0,
            1,
            0
        )
)

 


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

I think you need a subtotal. Please refer

https://community.powerbi.com/t5/Desktop/Percentage-of-subtotal/td-p/95390

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors