Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Changing the date when comparing values

Hi,

I'm doing some calculations where I calculate the values +1 day and +8 days against the selected date. But when I'm selecting a date in first table the date doesn't change in the other tables. I tried using it with a date table and also creating extra columns in my Table1 but nothing seems to work. Can someone help me and tell me if it is even possible?

 

#1

 

 

#2

When selected the expected date should be: 

demand vs supply = Selected date (ex. 12/06/2019)

+1 day = Selected date +1 (ex. 12/07/2019)

+8 day = Selected date +8 (ex. 12/14/2019)

 

 

Relationships

 

I'm not using any, everything is data from the same view. I can use a date table and for the the relationship would be:

date | one to Many (1:*) |  table

 

Data

The data is saved in a pivoted table where the column names are in 'attribute_name' and the values from the table are in 'value'. 

 

 

Measure's

I'm using 2 measures to calculate the difference for the +1 Day and 2 measures to calculate +8 Days. Below is the one for +1 Day.

 

Measure 1 - getting the value for +1 day


#1_Selecting_+1Day = VAR PriorDay = SELECTEDVALUE(table1[date])+1

RETURN
CALCULATE(
( SUM(table1[Value])),
ALL ( table1[date]),
table1[date] = PriorDay
)

 

Measure 2 - getting the difference for the two days. 

 

#2_Subtraction_from_prev_day = [#1_Selecting_+1Day] - SUM(table1[Value])

 

 

I hope someone can help me, if you need more information please let me know. 

  • Hi Anonymous ,

     

    You need measures as below:

    For +1 day:

     

    +1day = SELECTEDVALUE('Table'[Date])+1
    +1 value = SELECTEDVALUE('Table'[Value])+1

     

    For +8 days:

     

    +8 day = SELECTEDVALUE('Table'[Date])+8
    +8 value = SELECTEDVALUE('Table'[Value])+8

     

    Finally ,you will see:

     

     

    For the related .pbix file,pls click here.

     

    Best Regards,
    Kelly

7 Replies