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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.