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
huguest
Advocate II
Advocate II

Report the latest or blank date value

Hello,

 

I have top level issues that can have one or more items underneath it.  I am trying to report the completion date for each Issue that represents the completion of the latest item for that Issue. 

 

The first table is an example of the table with Issues and Items (+ Completion Date), and I need help getting the Completion Date in the second table (without the Item).

 

IssueItemCompletion Date
51112017-01-01
5121 
51312017-01-01
51322017-01-31
51412017-01-01
5142 

 

IssueCompletion Date
5112017-01-01
512 
5132017-01-31
514 

 

"Latest" gives me the date of the last completed item, but it doesn't quite work if I have issues that haven't been completed yet.  

 

If I have multiple items and one of them has not been completed yet, I need the date value for that issue to remain blank. 

 

Thanks.

1 ACCEPTED SOLUTION

A Power Query solution:

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Issue", Int64.Type}, {"Item", Int64.Type}, {"Completion Date", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Issue"}, {{"Completion Date", each Table.Max(_,"Item")[Completion Date], Value.Type(#"Changed Type")}})
in
    #"Grouped Rows"
Specializing in Power Query Formula Language (M)

View solution in original post

4 REPLIES 4
huguest
Advocate II
Advocate II

@Zubair_Muhammad thank you for your help.  I tried it but got an error while trying to create the Table "A table of multiple values was supplied where a single value was expected"....

 

I tied another approach where I copied the date column and replaced the balnk dates with 2999-12-31.  That allows me to get those using "latest".

 

Hugues.

A Power Query solution:

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Issue", Int64.Type}, {"Item", Int64.Type}, {"Completion Date", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Issue"}, {{"Completion Date", each Table.Max(_,"Item")[Completion Date], Value.Type(#"Changed Type")}})
in
    #"Grouped Rows"
Specializing in Power Query Formula Language (M)
Zubair_Muhammad
Community Champion
Community Champion

Hi @huguest

 

Please try this

 

Go to Modelling TAB>>>> NEW TABLE .......Then Enter this formula

 

New Table =
SUMMARIZE (
    TableName,
    TableName[Issue],
    "Completion Date",
    VAR mymax =
        CALCULATE ( MAX ( TableName[Item] ), ALLEXCEPT ( TableName, TableName[Issue] ) )
    RETURN
        CALCULATE (
            VALUES ( TableName[Completion Date] ),
            FILTER ( VALUES ( TableName ), TableName[Item] = mymax )
        )
)

Regards
Zubair

Please try my custom visuals

@huguest

 

1059.png


Regards
Zubair

Please try my custom visuals

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.