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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It 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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.