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
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 )
    )

Regards
Zubair

Please try my custom visuals

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] ) )
)

Regards
Zubair

Please try my custom visuals
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 )
)

Regards
Zubair

Please try my custom visuals
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


Regards
Zubair

Please try my custom visuals
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 )
    )

Regards
Zubair

Please try my custom visuals

@Anonymous 

 

Your file attached as well with above and previous measures

 

 


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.