cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Resolver II
Resolver II

Syntax for Cumulative Count Measure with multiple Criteria

Hi,

I have this cumulative measure which works ok:

 

 

 

Cumulative Change Notes =
CALCULATE (
    COUNTA ( Company_Documents[ID] ),
    FILTER (
        ALLSELECTED ( Company_Documents ),
        Company_Documents[DOC_CREATION_DATE]
            <= MAX ( Company_Documents[DOC_CREATION_DATE] )
    )
)

 

 

However i'd like to limit the result by adding an additional criteria to the filter (starts &&)

 

 

Cumulative Change Notes =
CALCULATE (
    COUNTA ( Company_Documents[ID] ),
    FILTER (
        ALLSELECTED ( Company_Documents ),
        Company_Documents[DOC_CREATION_DATE]
            <= MAX ( Company_Documents[DOC_CREATION_DATE] )
            && Company_Documents[Document Class] = "Change Note"
    )
)

 

 

 

I must have the incorrect syntax as there are no records returned despite records being available which match the criteria.

Can anyone give me a pointer on where i've gone wrong when adding the additional filter criteria?

Thanks,
Richard

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User V
Super User V

Re: Syntax for Cumulative Count Measure with multiple Criteria

Hi @RichardJ 

 

Try this.

Cumulative Change Notes =
VAR __maxCreationDate = MAX ( Company_Documents[DOC_CREATION_DATE] )
RETURN 
CALCULATE (
    COUNTA ( Company_Documents[ID] ),
    ALLSELECTED ( Company_Documents ),
    Company_Documents[DOC_CREATION_DATE] <= __maxCreationDate,
    Company_Documents[Document Class] = "Change Note"
)
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

Highlighted
Super User V
Super User V

Re: Syntax for Cumulative Count Measure with multiple Criteria

Hi @RichardJ

Try this instead, if it does not work consider creating a data sample so we can test and apply formulas.

 
Cumulative Change Notes =
VAR __maxCreationDate = MAX ( Company_Documents[DOC_CREATION_DATE] )
RETURN
CALCULATE (
COUNTROWS( Company_Documents ),
FILTER(
ALLSELECTED ( Company_Documents[DOC_CREATION_DATE], Company_Documents[Document Class] ),
AND(
Company_Documents[DOC_CREATION_DATE] <= __maxCreationDate,
Company_Documents[Document Class] = "Change Note"
)
)​
 
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

View solution in original post

4 REPLIES 4
Highlighted
Super User V
Super User V

Re: Syntax for Cumulative Count Measure with multiple Criteria

Hi @RichardJ 

 

Try this.

Cumulative Change Notes =
VAR __maxCreationDate = MAX ( Company_Documents[DOC_CREATION_DATE] )
RETURN 
CALCULATE (
    COUNTA ( Company_Documents[ID] ),
    ALLSELECTED ( Company_Documents ),
    Company_Documents[DOC_CREATION_DATE] <= __maxCreationDate,
    Company_Documents[Document Class] = "Change Note"
)
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

Highlighted
Resolver II
Resolver II

Re: Syntax for Cumulative Count Measure with multiple Criteria

@Mariusz Many Thanks for the idea and the quick reply.

 

This works perfectly.

 

Initially I didn't think it had worked as I wasn't giving it enough time to calculate (circa 5 seconds) the response.


Thanks again,

Richard

Highlighted
Super User V
Super User V

Re: Syntax for Cumulative Count Measure with multiple Criteria

Hi @RichardJ

Try this instead, if it does not work consider creating a data sample so we can test and apply formulas.

 
Cumulative Change Notes =
VAR __maxCreationDate = MAX ( Company_Documents[DOC_CREATION_DATE] )
RETURN
CALCULATE (
COUNTROWS( Company_Documents ),
FILTER(
ALLSELECTED ( Company_Documents[DOC_CREATION_DATE], Company_Documents[Document Class] ),
AND(
Company_Documents[DOC_CREATION_DATE] <= __maxCreationDate,
Company_Documents[Document Class] = "Change Note"
)
)​
 
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

View solution in original post

Highlighted
Resolver II
Resolver II

Re: Syntax for Cumulative Count Measure with multiple Criteria

@Mariusz - The linked file shows the formulas you provided working. perfectly.

I had to roll back my actual file (not this extract) to get it working properly as it had become corrupted in some way.

Hopefully the attached working example will help someone in future.

Thanks again @Mariusz - getting a solution for this made my day.

Cheers,

Richard

 

Cumulative Total, then broken down cumulative sub sectionsCumulative Total, then broken down cumulative sub sections

 

Helpful resources

Announcements
Ignite

Microsoft Ignite

This will be a conference that you do not want to miss!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Don't miss the Power BI Dev Camp this week!

August Community Highlights

Check out a full recap of the month!

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.