Forum Discussion

BhavyaM's avatar
BhavyaM
Icon for Helper V rankHelper V
6 years ago

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

    • BhavyaM's avatar
      BhavyaM
      Icon for Helper V rankHelper V

      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.

       

       

       

      • BhavyaM's avatar
        BhavyaM
        Icon for Helper V rankHelper V

        Can you please help how to work with API

  • v-yingjl's avatar
    v-yingjl
    Icon for Community Support rankCommunity Support

    Hi BhavyaM ,

    I have created a sample table:

    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:

     

    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.