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
AmitSaini
Helper I
Helper I

Need to getting latest date rows only against duplicate dates and unique dates

Hi Team,

I need your help to get the desired output in Power BI DAX.

Below is my dataset:

ProjectNameRunIdDateTimeTotalTestCoveredLineTotalLine
Sky46454509/19/202478767537611
Sky46651810/03/202478767537611
Sky46872010/18/202479568377693
Sky47085811/05/202479568447699
Sky47479412/02/202480869337790
Sky47567812/06/202480869327790
Sky48088201/16/202581569747826
Spark46290109/11/2024124600
Spark46300009/11/202412463471252198
Spark46614110/01/202412463471952254
Spark46717510/08/202412743503752745
Spark47442011/28/202412703503352737
Spark47473412/02/202412703503352737
Spark48168001/23/202513043544153393
Spark48176301/23/202513043544153393
Spark48204701/24/20258903235448254
Spark48215401/24/202513043545053402
Radiance46093708/29/2024656184404
Radiance46116908/30/2024452324404
Radiance46122708/30/2024126181547
Radiance46122908/30/2024652001100
Vision Venture47617912/10/2024789771629
Vision Venture47900401/03/20258412421629
Vision Venture47969201/08/20258412461641

I have a projectName filter on my report, and it is set for single selection only. I need to show the latest date data rows only in three different KPIs.

See example below:

AmitSaini_0-1740491458219.png

In my dataset, for some projects, I have more than one same date [duplicate dates for last rows] for the month. In this scenario, we should consider only the last rows.

For example:

  • If I select the project "Sky," the result should be shown in the KPI against the latest date [01/16/2025]:

    • Total Test: 815

    • Covered Line: 6974

    • Total Line: 7826

  • If I select the project "Spark," there are two entries for the last date [01/24/2025]. In this case, we should consider only the last rows, and the result should be shown in the KPI:

    • Total Test: 1304

    • Covered Line: 35450

    • Total Line: 53402

  • If I select the project "Radiance," there are three entries for the last date [08/30/2024]. In this case, we should consider only the last rows, and the result should be shown in the KPI:

    • Total Test: 65

    • Covered Line: 200

    • Total Line: 1100

 

1 ACCEPTED SOLUTION
Irwan
Super User
Super User

hello @AmitSaini 

 

please check if this accomodate your need.

Irwan_0-1740627199694.png

Irwan_1-1740627217657.png

Irwan_3-1740627351390.png

 

create three new measures with following DAX.

Total Test = 
var _RunId =
CALCULATE(
    MAX('Table'[RunId])
)
Return
CALCULATE(
    MAX('Table'[TotalTest]),
    'Table'[RunId]=_RunId
)
Total Lines = 
var _RunId =
CALCULATE(
    MAX('Table'[RunId])
)
Return
CALCULATE(
    MAX('Table'[TotalLine]),
    'Table'[RunId]=_RunId
)
Covered Lines = 
var _RunId =
CALCULATE(
    MAX('Table'[RunId])
)
Return
CALCULATE(
    MAX('Table'[CoveredLine]),
    'Table'[RunId]=_RunId
)
 
Hope this will help.
Thank you.

View solution in original post

2 REPLIES 2
Irwan
Super User
Super User

hello @AmitSaini 

 

please check if this accomodate your need.

Irwan_0-1740627199694.png

Irwan_1-1740627217657.png

Irwan_3-1740627351390.png

 

create three new measures with following DAX.

Total Test = 
var _RunId =
CALCULATE(
    MAX('Table'[RunId])
)
Return
CALCULATE(
    MAX('Table'[TotalTest]),
    'Table'[RunId]=_RunId
)
Total Lines = 
var _RunId =
CALCULATE(
    MAX('Table'[RunId])
)
Return
CALCULATE(
    MAX('Table'[TotalLine]),
    'Table'[RunId]=_RunId
)
Covered Lines = 
var _RunId =
CALCULATE(
    MAX('Table'[RunId])
)
Return
CALCULATE(
    MAX('Table'[CoveredLine]),
    'Table'[RunId]=_RunId
)
 
Hope this will help.
Thank you.

Hi @Irwan 

Thank you for the solution. It works really well.

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.