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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
karolp
Frequent Visitor

Measure returning if the cumulative count value is max value or not

Hello

 

I would like to kindly ask you to help me with following problem.

I use a measure to count cumulative number of the measurements of unique product Id. I need it to filter only the first measurement of every product and remove all the next measurements (if exist) from visualization.

Below the output example:

karolp_0-1697550512068.png

The measure which I use:

 

CummulativeCount = 
CALCULATE (
    COUNT (Append1[Id]),
    FILTER (
        ALLSELECTED (Append1),
        Append1[Id] = SELECTEDVALUE (Append1[Id])
        && Append1[DateTime] <= SELECTEDVALUE(Append1[DateTime])
    )
)

 

 

And this work totally OK- I am able to easy filter only the first measurement of every product Id.

 

But right now I need also a second measure (or other solution), which will help me to filter only the last measurement of every product Id. So for one product Id it can be the 1st measurement, but for another product Id it can be a f.e. 4th measurement.

 

So can anyone please help me with a measure solution (or other solution) which return if the cumulative count for every unique product Id is the max value or not?

Below an output example, which would fit perfect for me. In column MaxCumulativeCount the "1" means last measurement and the "0" means not last measurement.

karolp_1-1697551374661.png

 

Any help is appreciated

1 ACCEPTED SOLUTION
karolp
Frequent Visitor

Hello together

 

Thank you for all proposed solutions! Unfortunately I could not receive required result using your proposals. The measures were assigning the same value - last or blank - to all records.

 

But nevertheless I found a working solution. I use the solution of belisqui  from link to create calculated column.

 

LastMeasurement = 

IF (
    ALL_AKC[DateTime] = CALCULATE( MAX(ALL_AKC[DateTime]), FILTER(ALL_AKC, ALL_AKC[Id] = EARLIER(ALL_AKC[Id])))
    ,true()
    ,false()
)

 

The received result:

karolp_0-1697731438662.png

All last measurement of every unique ID are set as true. 

 

Thank you all again for support!

View solution in original post

7 REPLIES 7
karolp
Frequent Visitor

Hello together

 

Thank you for all proposed solutions! Unfortunately I could not receive required result using your proposals. The measures were assigning the same value - last or blank - to all records.

 

But nevertheless I found a working solution. I use the solution of belisqui  from link to create calculated column.

 

LastMeasurement = 

IF (
    ALL_AKC[DateTime] = CALCULATE( MAX(ALL_AKC[DateTime]), FILTER(ALL_AKC, ALL_AKC[Id] = EARLIER(ALL_AKC[Id])))
    ,true()
    ,false()
)

 

The received result:

karolp_0-1697731438662.png

All last measurement of every unique ID are set as true. 

 

Thank you all again for support!

AilleryO
Memorable Member
Memorable Member

Hi,
It might not be the best solution, but you could test as you did for your cumultive count, something like :

VAR LastDateOfID = MAX or LASTDATE( YourDate ) 
RETURN
IF ( YourDate = LastDateOfID , "last one" , BLANK() )

Hope it helps, let us know

Hello

 

first for all thank you for the support!

 

Unfortunately the proposed solution does not seem to work.

I tried to put it in various combinations, but there is always some error.

Example below:

karolp_0-1697624069508.png

If 'Max or' will be removed than the same error is for RETURN etc.

I hope I also past the correct column from my data set - which is a date/time column -  in the column described by you as 'YourDate'.

If I did something wrong please let me know.

Anonymous
Not applicable

Try SelectedValue('Table'[Date]) = Max('Table'[Date]) or LastDate('Table'[Date]). Because Max () or LastDate () returns a singular value. 

VAR LastDateOfID = MAX(YourDate) 

OR

VAR LastDateOfID = LASTDATE(YourDate) 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




karolp
Frequent Visitor

Hello

 

I checked it before as well. Unfortunately it does not work as well. The RETURN error appears.

karolp_0-1697630563114.png

 

karolp_1-1697630844108.png

 

Hi,

 

Those are 2 neew measures you should create and you should like for all meausres gives them a name. It should begin with the name:

NameOfMeasure = LASTDATE....

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.