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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
dudeeee
Frequent Visitor

show date and other column values of rows with min and max date in separate cards

DatevalueAvalueB
2022-09-129
 33
2022-08-2356
2022-09-1969
2022-09-1787

Hello , I am new to power bi and been stuck with this problem for a while. From above sample table I want to get the values of date, valueA and valueB for maximum and minimum date excluding the empty date.

I want to display the data from two rows in separate card visuals. I want it to work after application of other filters/slicers as well. 

1 ACCEPTED SOLUTION

@dudeeee 

Please try

Card A Max =
VAR T1 =
ADDCOLUMNS (
FILTER ( VALUES ( 'Table'[Date] ), 'Table'[Date] <> BLANK () ),
"@Value", CALCULATE ( SUM ( [Value A] ) )
)
VAR T2 =
TOPN ( 1, T1, [@Value], DESC )
VAR MaxValueDate =
MAXX ( T2, 'Table'[Date] )
VAR T3 =
FILTER ( 'Table', 'Table'[Date] = MaxValueDate )
RETURN
CONCATENATEX ( T3, [Date] & UNICHAR ( 10 ) & [@Value], UNICHAR ( 10 ) )

View solution in original post

6 REPLIES 6
tamerj1
Super User
Super User

@dudeeee 

Please try

Card A Max =
VAR T1 =
ADDCOLUMNS (
FILTER ( VALUES ( 'Table'[Date] ), 'Table'[Date] <> BLANK () ),
"@Value", CALCULATE ( SUM ( [Value A] ) )
)
VAR T2 =
TOPN ( 1, T1, [@Value], DESC )
VAR MaxValueDate =
MAXX ( T2, 'Table'[Date] )
VAR T3 =
FILTER ( 'Table', 'Table'[Date] = MaxValueDate )
RETURN
CONCATENATEX ( T3, [Date] & UNICHAR ( 10 ) & [@Value], UNICHAR ( 10 ) )

dudeeee
Frequent Visitor

@tamerj1 

valueA and valueB are columns from the source table

@dudeeee 
Here is same but fixed some errors

Card A Max =
VAR T1 =
    ADDCOLUMNS (
        FILTER ( VALUES ( 'Table'[Date] ), 'Table'[Date] <> BLANK () ),
        "@Value", CALCULATE ( SUM ( [Value A] ) )
    )
VAR T2 =
    TOPN ( 1, T1, [@Value], DESC )
RETURN
    CONCATENATEX (
        T2,
        [Date] & UNICHAR ( 10 ) & [@Value],
        UNICHAR ( 10 ),
        [Date], ASC
    )
Card A Min =
VAR T1 =
    ADDCOLUMNS (
        FILTER ( VALUES ( 'Table'[Date] ), 'Table'[Date] <> BLANK () ),
        "@Value", CALCULATE ( SUM ( [Value A] ) )
    )
VAR T2 =
    TOPN ( 1, T1, [@Value], ASC)
RETURN
    CONCATENATEX (
        T2,
        [Date] & UNICHAR ( 10 ) & [@Value],
        UNICHAR ( 10 ),
        [Date], ASC
    )

hello, @tamerj1 I think I am near to the solution.

Is it possible to get only the value but not its sum returned.

DatevalueAvalueB
2022-09-129
 33
2022-08-2356
2022-09-1969
2022-09-1787

I just want to get result as:

     Min                     Max

2022-08-23        2022-09-19

5                                 6

6                                 9

And show them in separate cards.

 

@dudeeee 

Please try

Card A Max =
VAR T1 =
ADDCOLUMNS (
FILTER ( VALUES ( 'Table'[Date] ), 'Table'[Date] <> BLANK () ),
"@Value", CALCULATE ( SUM ( [Value A] ) )
)
VAR T2 =
TOPN ( 1, T1, [@Value], DESC )
VAR MaxValueDate =
MAXX ( T2, 'Table'[Date] )
VAR T3 =
FILTER ( 'Table', 'Table'[Date] = MaxValueDate )
RETURN
CONCATENATEX ( T3, [Date] & UNICHAR ( 10 ) & [@Value], UNICHAR ( 10 ) )

tamerj1
Super User
Super User

Hi @dudeeee 

Are Value A and Value B measures or columns in the source data table?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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