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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
James_Ma
Helper I
Helper I

Show values of a field by first and last date.

Hi, I am trying to show a field value (which is a score rating) for multiple appointments for the same case.

 

So for example contact A has 5 appointments logged for Case1 and the first appointment was on the 1/01/2021 and the last appointment was on hte 28/02/2021.

 

the field for the score rating sits within the appointment table and only 3 appointments have a score.

 

How can I upll the data to show the first appointment date (with a score) and he last appointment date (with a score)?

 

Help is always appreciated

 

 

1 ACCEPTED SOLUTION

Hi  @James_Ma ,

 

Create 2 measures as below:

The first date =
VAR _mindate =
    CALCULATE (
        MIN ( 'Table'[Date of Assessment] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Case ID] = MAX ( 'Table'[Case ID] )
                && 'Table'[Full Name] = MAX ( 'Table'[Full Name] )
                && (
                    'Table'[Q1 score] <> BLANK ()
                        || 'Table'[Q2 score] <> BLANK ()
                )
        )
    )
RETURN
    _mindate
The last date =
VAR _maxdate =
    CALCULATE (
        MAX ( 'Table'[Date of Assessment] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Case ID] = MAX ( 'Table'[Case ID] )
                && 'Table'[Full Name] = MAX ( 'Table'[Full Name] )
                && (
                    'Table'[Q1 score] <> BLANK ()
                        || 'Table'[Q2 score] <> BLANK ()
                )
        )
    )
RETURN
    _maxdate

And you will see:

vkellymsft_0-1635818231571.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

 

View solution in original post

5 REPLIES 5
KNP
Super User
Super User

Hi @James_Ma - If this is still an issue for you, can you please post some sample data? It should be relatively simple to solve.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Hi KNP,

Thanks for your response, in reality a DAX expression would be perfect, I have a small data file which has hte relevant fields and I just want the Meaasure to pull the first date that has a score and hte last date that has a score.

Date of AssessmentCase IDFull NameAssessments IDQ1 scoreQ2 score
07/06/2021 00:00e0c41db5-1219-4794-ae4f-680f409e3a59Contact 102cd84aa-aec7-eb11-bacc-000d3a86ef21177
30/04/2021 00:00e0c41db5-1219-4794-ae4f-680f409e3a59Contact 10b13cdca-c8a9-eb11-9442-002248001f1f1921
04/06/2021 00:00e0c41db5-1219-4794-ae4f-680f409e3a59Contact 10e3452b2-bebf-eb11-bacc-0022481a610c  
13/08/2021 00:00e0c41db5-1219-4794-ae4f-680f409e3a59Contact 13cb46205-23fc-eb11-94ef-0022481b495a1917
07/05/2021 00:00e0c41db5-1219-4794-ae4f-680f409e3a59Contact 14c764874-6fae-eb11-8236-002248005e202119
14/05/2021 00:00e0c41db5-1219-4794-ae4f-680f409e3a59Contact 172a7768f-4daf-eb11-8236-0022480050a8  
25/06/2021 00:00e0c41db5-1219-4794-ae4f-680f409e3a59Contact 17d56baa3-95d5-eb11-bacb-0022481aaa552017
18/06/2021 00:00e0c41db5-1219-4794-ae4f-680f409e3a59Contact 1c255e553-aec7-eb11-bacc-000d3a86ef21177
28/05/2021 00:00e0c41db5-1219-4794-ae4f-680f409e3a59Contact 1d74e4662-66bc-eb11-bacc-0022481a6e41177
21/05/2021 00:00e0c41db5-1219-4794-ae4f-680f409e3a59Contact 1fb585a25-52b9-eb11-8236-00224800ee201919

Hi @James_Ma,

 

Sorry I missed your reply.

If you're happy with a DAX expression then I suspect @Greg_Deckler's answer will work. If you still want Power Query then I'll have a look for you.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Hi  @James_Ma ,

 

Create 2 measures as below:

The first date =
VAR _mindate =
    CALCULATE (
        MIN ( 'Table'[Date of Assessment] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Case ID] = MAX ( 'Table'[Case ID] )
                && 'Table'[Full Name] = MAX ( 'Table'[Full Name] )
                && (
                    'Table'[Q1 score] <> BLANK ()
                        || 'Table'[Q2 score] <> BLANK ()
                )
        )
    )
RETURN
    _mindate
The last date =
VAR _maxdate =
    CALCULATE (
        MAX ( 'Table'[Date of Assessment] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Case ID] = MAX ( 'Table'[Case ID] )
                && 'Table'[Full Name] = MAX ( 'Table'[Full Name] )
                && (
                    'Table'[Q1 score] <> BLANK ()
                        || 'Table'[Q2 score] <> BLANK ()
                )
        )
    )
RETURN
    _maxdate

And you will see:

vkellymsft_0-1635818231571.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

 

Greg_Deckler
Super User
Super User

@James_Ma This is Lookup Min/Max: 

 

Lookup Max Simple = 
    VAR __Table = 'Table'
    VAR __Max = MAXX(__Table,[Date])
RETURN
    MAXX(FILTER(__Table,[Date] = __Max),[Column])


Lookup Min Simple = 
    VAR __Table = 'Table'
    VAR __Min = MINX(__Table,[Date])
RETURN
    MAXX(FILTER(__Table,[Date] = __Min),[Column])

 

Lookup Min/Max - Microsoft Power BI Community 

 

And now I just realized that you want Power Query and this is a DAX solution. Oh well, if you are able to do it in DAX this is how. No idea in Power Query.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors