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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Getting the earliest value of a table visual

 

Hi,

 

I'm trying to create a dax measure for getting the earliest price of an item in a table visual and show that same value on every row.

However I'm having trouble in clearing the filter context of the table.

 

What I have now is this measure which works as a separate visual but not in a table visual:

FirstUNITPRICE =
CALCULATE (
    SUM ( Purchases[UNITPRICE] );
    FILTER ( ALL ( Purchases) ; Purchases[Date] = MIN ( Purchases[Date] ) )
)

 

 

What im trying to achieve is to show the same measure value of '92' in every row of the visual:

 

Capture.PNG 

I have a separate date table which I use as a slicer and also have it as date column in the table visual:

 

Capture.PNG

 

 

 

 

Any help would be appreciated.

 

 

Example .pbix

1 ACCEPTED SOLUTION

@Anonymous 

 

We can use this with DATETABLE{Date]

 

First_UNITPRICE =
VAR my_date =
    MINX (
        ALLSELECTED ( DateTable ),
        CALCULATE (
            MIN ( Purchases[Date] ),
            ALLEXCEPT ( Purchases, DateTable[Date] ),
            VALUES ( Purchases[ItemID] )
        )
    )
RETURN
    CALCULATE (
        SUM ( Purchases[UNITPRICE] ),
        Purchases[Date] = my_date,
        ALL ( purchases )
    )

View solution in original post

8 REPLIES 8
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

Try this one

 

FirstUNITPRICE =
CALCULATE (
    SUM ( Purchases[UNITPRICE] );
    FILTER ( ALL ( Purchases) ; Purchases[Date] = MIN ( DateTable[Date] ) )
)
Anonymous
Not applicable

Unfortunately the result is the same as above.

@Anonymous 

 

And this one?

 

FirstUNITPRICE = 
VAR mydate= CALCULATE(MIN ( DateTable[Date] ),ALLSELECTED())
RETURN
CALCULATE (
    SUM ( Purchases[UNITPRICE] ),
    FILTER ( ALL ( Purchases[Date]) , DateTable[Date] = mydate )
)
Anonymous
Not applicable

That returns a value only for the first row only if slicer start date is same than the line date.

I have attached the example .pbix to my original post.

image.png

@Anonymous 

 

This works with your file.

 

But I had to change Date from DateTable to Date from Purchases Table in your file

See the attached file please

 

FirstUNITPRICE = 
VAR my_date =
    CALCULATE (
        MIN ( Purchases[Date] ),
        FILTER ( ALL ( Purchases ), Purchases[Date] > MIN ( DateTable[Date] ) ),VALUES(Purchases[ItemID])
    )
RETURN
    CALCULATE (
        SUM ( Purchases[UNITPRICE] ),
        Purchases[Date] = my_date,
        ALL ( purchases )
    )

jujsho.png

Anonymous
Not applicable

I have a more complex report where I'm having this problem and that data model requires me to use the date column of separate date table. I'm trying to figure out if there is a way to do this while using the DateTable[Date] column.

@Anonymous 

 

We can use this with DATETABLE{Date]

 

First_UNITPRICE =
VAR my_date =
    MINX (
        ALLSELECTED ( DateTable ),
        CALCULATE (
            MIN ( Purchases[Date] ),
            ALLEXCEPT ( Purchases, DateTable[Date] ),
            VALUES ( Purchases[ItemID] )
        )
    )
RETURN
    CALCULATE (
        SUM ( Purchases[UNITPRICE] ),
        Purchases[Date] = my_date,
        ALL ( purchases )
    )

@Anonymous 

 

Your file attached as well with above and previous measures

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.