Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

measure

Hello,

Can you help with the following please?
There are three tables in model...

PTable
----------
PKey
PCode

myDate
---------
DateKey
DateValue
calendarDateYear
CalendarQuarter
StartQuarterYearMonthDay --> example of the existing data - following logic. no need to do anything here
i.e. if [Calendar Quarter] = 1 then CalendarDateYear & 0105
i.e. if [Calendar Quarter] = 2 then CalendarDateYear & 0405
i.e. if [Calendar Quarter] = 3 then CalendarDateYear & 0705
i.e. if [Calendar Quarter] = 4 then CalendarDateYear & 1005

Fact
--------
DateKey
PKey
UnitPrice
...

Question:
-------------
Using DAX, how is it possible to work out a measure for each row as follows:

In Fact Table, I would like to create two measures
Measure_1 = Previous day UnitPrice
Measure_2 = UnitPrice in Fact Table which matches the DateKey of StartQuarterYearMonthDay in myDate table

8 Replies

  • Anonymous , are you have a calendar that starts from 5th of every year and each qtr from 5th ?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi,
      The Date table has a column called StartQuarterYearMonthDayKey which has values like YYYYMMDD i.e. 20150105
      or 20191005, etc.
      Hope this helps

      Thank you

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

        Could you please provide some sample data in these three tables and the based fields if they have any relationship among them be created in order to provide you the suitable measures? Thank you.

        In addition,  you can refer the methods in the following threads to write Measure_1 and Measure_2:

        Previous day value

        Previous Day Value comparing

        Best Regards

        Rena