Power BI Exchange

Please login or click SIGN UP FOR FREE to create your PowerBIUG account to join this user group.
 View Only
  • 1.  Compare Value between two dates

    Bronze Contributor
    Posted Sep 19, 2019 06:57 AM

    Hello !

    I need two compare two value between two dates.

    I have a list with brand_name, terminal_description, product, price and date, and i need to know the price difference between two dates.
    So, i want to add a new column between two dates, which will show the price difference between that 2 dates.


    Thank you !


    ------------------------------
    Damini Gohil
    BI Developer
    ------------------------------


  • 2.  RE: Compare Value between two dates

    Top Contributor
    Posted Sep 20, 2019 03:35 AM
    Hi @Damini Gohil,

    You can filter the table using the MAX() function, which will give you the max date in the current filter context.
    Then you can filter the table again to find all the dates that are less than the max date and from the filtered table get the max date.
    For. e.g. Max date = 16th
    Then filter the date column with dates that are less than the 16th and find the max of that, which should be the 15th.
    Then using the LOOKUPVALUE() function you should be able to get the prices for both and then do the subtraction.

    You will need to use variables as it will make it easier to get the necessary pieces.

    Of course this is just a theory that could work.
    If you could upload your sample file, we can take a look at it.

    Hope this helps.

    Thank you,

    ------------------------------
    Vishesh Jain
    Owner
    VR Construction
    ------------------------------



  • 3.  RE: Compare Value between two dates

    Bronze Contributor
    Posted Oct 03, 2019 01:04 AM
    Thanks, but it does not work.

    ------------------------------
    Damini Gohil
    BI Developer
    ------------------------------



  • 4.  RE: Compare Value between two dates

    Top Contributor
    Posted Oct 03, 2019 03:49 AM
    Edited by Vishesh Jain Oct 03, 2019 03:49 AM

    Hi @Damini Gohil,

    If possible please can you share a sample file with us.

    Also, the dates in question here, of which you want to compare the prices, are these dates going to be consecutive or the could be any random 2 dates​?

    The DAX code will differ depending on how you plan to make the selection of dates.

    Thank you,



    ------------------------------
    Vishesh Jain
    Owner
    VR Construction
    ------------------------------



  • 5.  RE: Compare Value between two dates

    Bronze Contributor
    Posted Oct 04, 2019 02:35 AM
      |   view attached
    Hello @Vishesh Jain​,

    I want a difference between two dates which i have marked in picture and particular one column(difference between two dates) should be added between two date columns.

    Thank You,

    ------------------------------
    Damini Gohil
    BI Developer
    ------------------------------



  • 6.  RE: Compare Value between two dates

    Bronze Contributor
    Posted Oct 04, 2019 08:06 AM
    Edited by Mick Fitzpatrick Oct 04, 2019 09:54 AM
    You need to setup a Dates dimension containing every date you're likely to include, and create a relationship between this and your date_col.

    Then the following should work:
    SUM(Query1[price])-CALCULATE(SUM(Query1[price]), PREVIOUSDAY('Date_Dim'[Date]))

    There are probably better ways to do it !

    Mick

    ------------------------------
    Mick Fitzpatrick
    ------------------------------



  • 7.  RE: Compare Value between two dates

    Posted Dec 28, 2021 05:58 AM
    Hi, I recommend creating a second table as the comparison basis with an inactive relationship. Here is a video that explains this:

    https://youtu.be/knXFVf2ipro

    ------------------------------
    Theo Bv
    Data Analyst
    ------------------------------