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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
pbrainard
Helper III
Helper III

MIN and MAX Dates (and Scores) in Calculated Table

I have a bunch of rows that contain Assessment Dates and Scores.

I want to create a calculated table that pulls the MIN Date and score, and MAX Date and score for each client.

I created a caclulated table that gets the MIN and MAX Dates, but not sure how to pull the associated scores in too.

 

Here's the table calc bringing in the dates:

 

Table =
SUMMARIZE (
'GAD_PHQ',
GAD_PHQ[Client_ID],
GAD_PHQ[Full_Name],
"Start Date", MIN ( GAD_PHQ[Assess_Date] ),
"End Date", MAX ( GAD_PHQ[Assess_Date] )
1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

 

Table =
ADDCOLUMNS(
    SUMMARIZECOLUMNS(
        GAD_PHQ[Client_ID],
        "Start Date", MIN( GAD_PHQ[Assess_Date] ),
        "End Date", MAX( GAD_PHQ[Assess_Date] )
    ),
    "Start Score",
        CALCULATE(
            AVERAGE( GAD_PHQ[Assess_Score] ),
            GAD_PHQ[Assess_Date] = EARLIER( [Start Date] )
        ),
    "End Score",
        CALCULATE(
            AVERAGE( GAD_PHQ[Assess_Score] ),
            GAD_PHQ[Assess_Date] = EARLIER( [End Date] )
        )
)

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

 

Table =
ADDCOLUMNS(
    SUMMARIZECOLUMNS(
        GAD_PHQ[Client_ID],
        "Start Date", MIN( GAD_PHQ[Assess_Date] ),
        "End Date", MAX( GAD_PHQ[Assess_Date] )
    ),
    "Start Score",
        CALCULATE(
            AVERAGE( GAD_PHQ[Assess_Score] ),
            GAD_PHQ[Assess_Date] = EARLIER( [Start Date] )
        ),
    "End Score",
        CALCULATE(
            AVERAGE( GAD_PHQ[Assess_Score] ),
            GAD_PHQ[Assess_Date] = EARLIER( [End Date] )
        )
)

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Is there a way to add an additional filter so the results show Start Date and Score, End Date and Score, per Client ID AND Assessment Type? Right now, it's pulling Start and End per Client ID only.

tackytechtom
Most Valuable Professional
Most Valuable Professional

Hi @pbrainard ,

 

How about this one:

CalculatedTable =
SUMMARIZE (
   'GAD_PHQ',
   'GAD_PHQ'[Client_ID],
   'GAD_PHQ'[Full_Name],
   "Start Date", MIN ( 'GAD_PHQ'[Assess_Date] ),
   "Start Date Score", CALCULATE ( MAX ( 'GAD_PHQ'[Score] ), FILTER ( 'GAD_PHQ', 'GAD_PHQ'[Assess_Date] = MIN ( 'GAD_PHQ'[Assess_Date] ) ) ),
   "End Date",   MAX ( 'GAD_PHQ'[Assess_Date] ),
   "End Date Score",   CALCULATE ( MAX ( 'GAD_PHQ'[Score] ), FILTER ( 'GAD_PHQ', 'GAD_PHQ'[Assess_Date] = MAX ( 'GAD_PHQ'[Assess_Date] ) ) )
)

 

Does this work for you? 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Helpful resources

Announcements
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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

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