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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
evolu6ion
Frequent Visitor

Measures using measures as filters

Hello everyone,

 

Today, I am stuck at making a measure that has to deal with filters based on another measure result.

 

Here is a sample of my data and the problem that is appearing:

2019-05-21 14_32_47-Courbe des actifs - Power BI Desktop.png

 

In the matrix, I have 3 different customers and their purchases behavior. In the wide red rectangle, you can see that as long as their latest purchase date is farther than 24 months from the end of the current row month, the customer should not be calculated with the 'Nb of customers 24 months' measure. When this measure is in such matrix, it behaves as it should. But whenever I remove the 'Customer number' column, I do not manage to get the desired result (see (1) on the image above).

 

The desired result in this aggregated table would be:

YEARMONTHWRONG Nb of cust 24 monthDesired Result
2018March32
2018April32
2018May32
2018June32
2018July31
2018August31
2018September31
2018October31
2018November31

 

Here is the code used for the aformentioned measures:

TEMP Nb cust 24 month = 
COUNTA(Customer[Customer Number])

Nb cust 24 month = 
IF(
    [Nb of months since last purchase] >= 0 && [Nb of months since last purchase] <= 24;
    CALCULATE(
        [TEMP Nb cust 24 month];
        FILTER(
            ALL(Calendar[Date]);
            Calendar[Date] <= MAX(Calendar[Date])
        )
    );
    BLANK()
)

TEST Nb cust 24 month = 
VAR Cust = 
[Nb cust 24 month]
RETURN
CALCULATE(
    COUNTA(Customer[Customer Number]);
    FILTER(
        Sales;
        Cust >0
    )
)


The data model is a simple star schema with a Fact Sales table and 2 dimension tables (Customer and Calendar, with the Calendar table being linked to the fact with 'Sales date').

 

Your help would be much appreciated.

 

Thanks in advance.

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

Hi @evolu6ion 

It is invaild of this measure.

TEST Nb cust 24 month = 
VAR Cust = 
[Nb cust 24 month]
RETURN
CALCULATE(
    COUNTA(Customer[Customer Number]);
    FILTER(
        Sales;
        Cust >0
    )
)

 

Since the table doesn't contain [Customer Number] column,don't use [Customer Number] column in this measure, try to use other column.

Or add [Customer Number] column in the table visual.

 

Best Regards
Maggie

 

 

 

View solution in original post

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @evolu6ion 

It is invaild of this measure.

TEST Nb cust 24 month = 
VAR Cust = 
[Nb cust 24 month]
RETURN
CALCULATE(
    COUNTA(Customer[Customer Number]);
    FILTER(
        Sales;
        Cust >0
    )
)

 

Since the table doesn't contain [Customer Number] column,don't use [Customer Number] column in this measure, try to use other column.

Or add [Customer Number] column in the table visual.

 

Best Regards
Maggie

 

 

 

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.