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
JolienR
Helper II
Helper II

Count TRUE/FALSE expression resulting from measure

Hi, 

 

All the columns are measures, expect for the ID_CUSTOMER_GUID. 
I am trying to count how many times DidUserPurchaseInBothPeriods is True.

JolienR_0-1660914735992.png

 

Currently I am trying it like this, however it is not working as you can see the result is 1: 

COUNTAX(FILTER(MetingenKlanten;[DidUserPurchaseInBothPeriods]=TRUE());TRUE())
 
Hopefully someone can help me. 
7 REPLIES 7
amitchandak
Super User
Super User

@JolienR , Create a measure like

 

Countx(Values(Table[ID_CUSTOMER_GUID]) , if( not(Isblank([Measure12 month])) && not(Isblank([Measure 6 month])) , [ID_CUSTOMER_GUID], blank() ) )

 

 

same logic as retain customer, measures of your choice

Customer Retention Part 1:
https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-1-Month-on-Month-Retention/b...

Hi @amitchandak 

I created the measure: 

COUNTX(VALUES('table'[ID_CUSTOMER_GUID]); IF(NOT(ISBLANK([CustomerLast12-6MonthsNew])) && NOT(ISBLANK([CustomerLast6-0MonthsNew]));'table'[ID_CUSTOMER_GUID];blank()))

However as you can see at "Verloop Individueel 2" it is still not right since last12-6months and last6-0 months are both 1, however the measure is not counting it. 
JolienR_0-1660915917798.png

 

Hi @JolienR ,

Please create two measures as below first, then put the measure [Verloop Individueel 2] onto your visual:

Measure =
IF (
    NOT ( ISBLANK ( [CustomerLast12-6MonthsNew] ) )
        && NOT ( ISBLANK ( [CustomerLast6-0MonthsNew] ) ),
    1,
    BLANK ()
)
Verloop Individueel 2 = SUMX ( VALUES ( 'table'[ID_CUSTOMER_GUID] ), [Measure] )

If the above one can't help you get the desired result, please provide some raw data in your table (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

This solution worked great for me. Thank you. 🙂

Hi @v-yiruan-msft,

 

Thank you for your response. 
As you can see the measure DidUserPurchaseInBothPeriods2 is showing 1, however Verloop individueel 2 is not counting it. I can not upload a file, so I uploaded it in Drive: https://drive.google.com/file/d/165tLHHRih4h5iEvPNUxjBaVwNqff1F5J/view?usp=sharing

JolienR_0-1661243823580.png

 

 

The measures I used for CustomerLast12-6MonthsNew and CustomerLast6-0MonthsNew are: 

CustomerLast12-6MonthsNew =
var maxDate = MAX('Calendar'[Date])
var StarDate = MINX(FILTER(DATESINPERIOD('Calendar'[Date]; maxDate; -6; MONTH ); 'Calendar'[Date]);'Calendar'[Date])
var result = CALCULATE(DISTINCTCOUNTNOBLANK('table'[ID_CUSTOMER_GUID]); DATESINPERIOD('Calendar'[Date]; StarDate; -6; MONTH ))

return result
 
CustomerLast6-0MonthsNew =
var maxDate = MAX('Calendar'[Date])
var result = CALCULATE(DISTINCTCOUNTNOBLANK('table'[ID_CUSTOMER_GUID]); DATESINPERIOD('Calendar'[Date]; maxDate; -6; MONTH ))
return result
 
Thank you in advance!!

Hi @JolienR ,

Please update the formula of the measure [Verloop Individueel 2] as below to get it and check it can get the correct result:

Verloop Individueel 2 =
VAR _flag =
    MAXX (
        VALUES ( 'MetingenKlanten'[ID_CUSTOMER_GUID] ),
        [DidUserPurchaseInBothPeriods]
    )
RETURN
    COUNTX (
        FILTER ( 'MetingenKlanten', _flag = TRUE () ),
        'MetingenKlanten'[ID_CUSTOMER_GUID]
    )

Best Regards

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

Hi @v-yiruan-msft 

I get an error: The function MAXX cannot work with values of type Boolean.

 

What I do not understand is the following (dont mind the numbers for Verloop Individueel, I used changed it quick). As you can see 05039023-FD41-4791-AE53-A3887E6D2FEE did purchased in both periods, but Verloop Individueel is not counting it. When I copy this value en paste it in the filter for ID_CUSTOMER_GUID, the visual is not showing any data. I have a filter on this page for one of our store locations. However if I look in the raw data, this customer ID belongs to this store location. 

JolienR_0-1661412348097.png

JolienR_1-1661412504108.png

 

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.