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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
japolo
Frequent Visitor

Row count of one column and returning the max value

Hi,

The subject title was a bit hard to make sense of but i'm trying to explain the issue below.

I have a table with multiple columns where the ID is the same, but the timestamp, shape and sequence number is different. 

What I want to return is the count of 1 based on shape. The sequence number is higher based on the last shape selected, and the max timestamp_when_select is the latest selection. So in the image below, "2021-11-30 03:53:56 with the nbr of 25 is the one I want to return.
How do I make it correct so the shape "planned2D_rec" gets the count and no other shape)

japolo_1-1661159949567.png

Kindly,

J

 

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

Hi, @japolo ;

 

 You could try it.

 

Measure = CALCULATE(COUNT('Table'[shape]),FILTER(ALL('Table'),[shape]=
CALCULATE(MAX('Table'[shape]),FILTER('Table',[timestamp]= CALCULATE(MAX('Table'[timestamp]),ALLEXCEPT('Table','Table'[planning_id]))))))

 

The final show:

AilsaTao_0-1661415243030.png


Best Regards,
Community Support Team _ Yalan Wu
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-yalanwu-msft
Community Support
Community Support

Hi, @japolo ;

 

 You could try it.

 

Measure = CALCULATE(COUNT('Table'[shape]),FILTER(ALL('Table'),[shape]=
CALCULATE(MAX('Table'[shape]),FILTER('Table',[timestamp]= CALCULATE(MAX('Table'[timestamp]),ALLEXCEPT('Table','Table'[planning_id]))))))

 

The final show:

AilsaTao_0-1661415243030.png


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

tamerj1
Super User
Super User

Hi @japolo 
Please try

New Column =
VAR CurrentIDTable =
    CALCULATETABLE ( TableName, ALLEXCEPT ( TableName, TableName[Planning_id] ) )
VAR SummaryTable =
    SUMMARIZE ( CurrentIDTable, TableName[shape] )
VAR RequiredTable =
    GENERATE (
        SummaryTable,
        VAR Count =
            CALCULATE ( COUNTROWS ( TableName ) )
        VAR LastTimestamp =
            CALCULATE ( MAX ( TableName[timestamp_when_select] ) )
        VAR SequenceNbr =
            CALCULATE (
                MAX ( TableName[sequence_nbr] ),
                TableName[timestamp_when_select] = LastTimestamp
            )
        RETURN
            ROW ( "@Count", Count, "@SequenceNbr", SequenceNbr )
    )
VAR TopRecord =
    TOPN ( 1, RequiredTable, [@Count] )
RETURN
    MAXX ( TopRecord, [@SequenceNbr] )

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors