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
Anonymous
Not applicable

Count of users whose status flag changes from 0 to 1

Dear All,

 

I need help on writing DAX for calculating the count of customers whose status flag is changing from 0 to 1 in a particular month.

where 0 indicates new user (first order)and 1 indicates repeat user (2nd order).

Please help on writing DAX query for

1. No . of users whose  status flag changing from 0 to 1

2. And only count of users with status indicator 1 (exclude users with status flag changes from 0 to 1)  in a particular month

 

Repeate customer count.png

Thanks & Regards,

Rajeev Bikkani

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

Please create measures like below:

Count repeat =
CALCULATE (
    DISTINCTCOUNT ( Cust_Order[Cust_Ord_Rept_in] ),
    ALLSELECTED ( Cust_Order[Cust_Ord_Rept_in] )
)

count custom 1=
CALCULATE (
    DISTINCTCOUNT ( Cust_Order[Ord_Cust_Id] ),
    FILTER ( ALLEXCEPT ( Cust_Order, Cust_Order[Month] ), [Count repeat] = 2 )
)

count custom 2 =
CALCULATE (
    DISTINCTCOUNT ( Cust_Order[Ord_Cust_Id] ),
    FILTER (
        ALLEXCEPT ( Cust_Order, Cust_Order[Month] ),
        [Count repeat] = 1
            && Cust_Order[Cust_Ord_Rept_in] = 1
    )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

2 REPLIES 2
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

Please create measures like below:

Count repeat =
CALCULATE (
    DISTINCTCOUNT ( Cust_Order[Cust_Ord_Rept_in] ),
    ALLSELECTED ( Cust_Order[Cust_Ord_Rept_in] )
)

count custom 1=
CALCULATE (
    DISTINCTCOUNT ( Cust_Order[Ord_Cust_Id] ),
    FILTER ( ALLEXCEPT ( Cust_Order, Cust_Order[Month] ), [Count repeat] = 2 )
)

count custom 2 =
CALCULATE (
    DISTINCTCOUNT ( Cust_Order[Ord_Cust_Id] ),
    FILTER (
        ALLEXCEPT ( Cust_Order, Cust_Order[Month] ),
        [Count repeat] = 1
            && Cust_Order[Cust_Ord_Rept_in] = 1
    )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Yuliana,

 

Thankyou for providing the solution.

 

Thanks & Regards,

Rajeev Bikkani

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.