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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
BhavyaM
Helper V
Helper V

Live price

Hi,

 

I want to show live Oil price.

 

I have Oil price, daily date and material name fields. Using these fields I want to show live price. 

 

if there is any price today then we have to show today Live price. Else previous price value.

 

 

can you please help me how to do this

This is very urgent requirement 

 

Thanks in advance. 

4 REPLIES 4
v-yingjl
Community Support
Community Support

Hi @BhavyaM ,

I have created a sample table:

oil price.png

Create a measure like this:

Live price =
IF (
    SELECTEDVALUE ( 'Table'[Material name] ) = "A"
        && SELECTEDVALUE ( 'Table'[Daily date] ) = TODAY (),
    "Live price of A is today: "
        & CALCULATE (
            SUM ( 'Table'[Oil price] ),
            'Table'[Material name] = "A",
            'Table'[Daily date] = TODAY ()
        ),
    IF (
        SELECTEDVALUE ( 'Table'[Material name] ) = "A"
            && SELECTEDVALUE ( 'Table'[Daily date] ) <> TODAY (),
        "Live price of A is previous: "
            & CALCULATE (
                SUM ( 'Table'[Oil price] ),
                FILTER (
                    'Table',
                    'Table'[Material name] = "A"
                        && 'Table'[Daily date]
                            = CALCULATE (
                                MAX ( 'Table'[Daily date] ),
                                FILTER (
                                    'Table',
                                    'Table'[Material name] = "A"
                                        && 'Table'[Daily date] < TODAY ()
                                )
                            )
                )
            ),
        IF (
            SELECTEDVALUE ( 'Table'[Material name] ) = "B"
                && SELECTEDVALUE ( 'Table'[Daily date] ) = TODAY (),
            "Live price of B is today: "
                & CALCULATE (
                    SUM ( 'Table'[Oil price] ),
                    'Table'[Material name] = "B",
                    'Table'[Daily date] = TODAY ()
                ),
            IF (
                SELECTEDVALUE ( 'Table'[Material name] ) = "B"
                    && SELECTEDVALUE ( 'Table'[Daily date] ) <> TODAY (),
                "Live price of B is previous: "
                    & CALCULATE (
                        SUM ( 'Table'[Oil price] ),
                        FILTER (
                            'Table',
                            'Table'[Material name] = "B"
                                && 'Table'[Daily date]
                                    = CALCULATE (
                                        MAX ( 'Table'[Daily date] ),
                                        FILTER (
                                            'Table',
                                            'Table'[Material name] = "B"
                                                && 'Table'[Daily date] < TODAY ()
                                        )
                                    )
                        )
                    ),
                IF (
                    SELECTEDVALUE ( 'Table'[Material name] ) = "C"
                        && SELECTEDVALUE ( 'Table'[Daily date] ) = TODAY (),
                    "Live price of C is today: "
                        & CALCULATE (
                            SUM ( 'Table'[Oil price] ),
                            'Table'[Material name] = "C",
                            'Table'[Daily date] = TODAY ()
                        ),
                    IF (
                        SELECTEDVALUE ( 'Table'[Material name] ) = "C"
                            && SELECTEDVALUE ( 'Table'[Daily date] ) <> TODAY (),
                        "Live price of C is previous: "
                            & CALCULATE (
                                SUM ( 'Table'[Oil price] ),
                                FILTER (
                                    'Table',
                                    'Table'[Material name] = "C"
                                        && 'Table'[Daily date]
                                            = CALCULATE (
                                                MAX ( 'Table'[Daily date] ),
                                                FILTER (
                                                    'Table',
                                                    'Table'[Material name] = "C"
                                                        && 'Table'[Daily date] < TODAY ()
                                                )
                                            )
                                )
                            ),
                        BLANK ()
                    )
                )
            )
        )
    )
)

Use two slicers and a card visual to show the result:

re1.pngre2.png

 

Attached my sample file that you can refer: Live price.pbix

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@BhavyaM , Not very clear. If you have some API, you can get the data and show it.

Currently I am using share pint excel to delvelop reports so there will be BRM integration. So is it possible to develop current live price and difference of current and previous price and its percentage.

 

 

 

Can you please help how to work with API

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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