Forum Discussion

santoshlearner2's avatar
santoshlearner2
Resolver II
2 years ago
Solved

Daily changes

earlier i had posted this question but did not explain properly My knowledge is not that great in power bi, learning from all you guys. I tried solving it but cannot get it. Higly appreciate for taking time to reply. Thank you every one. 

 

I have daily stock item wise rate and units, where i a measure which gives the result. the issue is i have  matrix which shows itemwise changes,  Very IMP - it works only when i select the date in the slicer, when i try to put the date in the slicer it gives an error message. Please note the  previous date value and the current value is based on date selection.

 

Want the result like this, i get this result only when i select individual date, i cannot show a trend of the days

Product02-06-202403-06-202404-06-202405-06-2024
Bike512.55.586-1
Cycle0.1215-10.052.5
Pen-4.48712.814.5
Car07.513.24.5
Toy53.412-11.44
Pencil-15.61125-1

 

ProductDateRateUnitsUnit Change (A)Rate Change (B)Final Result (A X B) 
Bike31-05-202410.00100   
Cycle31-05-202420.00154   
Pen31-05-202430.00160   
Car31-05-202440.00210   
Toy31-05-202450.00230   
Pencil31-05-202460.00260   
       
Bike02-06-202410.50110100.505.00
Cycle02-06-202420.1215510.120.12
Pen02-06-202431.12156-41.12-4.48
Car02-06-202442.1521002.150.00
Toy02-06-202451.78260301.7853.40
Pencil02-06-202460.78240-200.78-15.60
       
Bike03-06-202411.00135250.5012.50
Cycle03-06-202420.62185300.5015.00
Pen03-06-202431.62170140.507.00
Car03-06-202442.65225150.507.50
Toy03-06-202452.28284240.5012.00
Pencil03-06-202461.28262220.5011.00
       
Bike04-06-202411.8014270.805.59
Cycle04-06-202422.63180-52.01-10.05
Pen04-06-202433.4517771.8312.81
Car04-06-202444.8523162.2013.20
Toy04-06-202457.98282-25.70-11.40
Pencil04-06-202463.78272102.5025.00
       
Bike05-06-202412.30140-20.50-1.00
Cycle05-06-202423.1318550.502.50
Pen05-06-202433.9518690.504.50
Car05-06-202445.3524090.504.50
Toy05-06-202458.4829080.504.00
Pencil05-06-202464.28270-20.50-1.00

 

 

  • Dear Yang,

     

    it is nice of you to reply, i truly appreciate it. The column marked in brackets viz A & B, ie 

    Unit Change (A)Rate Change (B)Final Result (A X B)

    This is derieved from minus the previous day values, which i get from a measure like current minus the previous etc.  This issue is when  i put the date in the slicer the values are correctly depicting, but if i put the same in the matrix, ( Since no date is selected) . It gives any error. 

     

    Thank you in advance for your much need assistance.

     

     

  • Alican_C's avatar
    Alican_C
    2 years ago

    Hi, I believe the measures you used causes it.
    I would handle them with calculated columns as follow:


    1st: 

    Daily Change =
    VAR PreviousDayUnits =
    CALCULATE(
    MAX(TableName[Units]),
    FILTER(
    TableName,
    TableName[Product] = EARLIER(TableName[Product]) &&
    TableName[Date] = EARLIER(TableName[Date]) - 1
    )
    )
    RETURN
    IF(
    ISBLANK(PreviousDayUnits),
    BLANK(),
    TableName[Units] - PreviousDayUnits
    )

    ---

    2nd: 

    Final Result = TableName[Daily Change]*TableName[Rate Change]

    Data table would look like this 

     

    And the matrix will work regardless of slicer selection:

     

6 Replies

  • sorry an addition to the this is when i use the date in the matrix it does not work

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, santoshlearner2 

    You can use matrix to acheive the arm.


    Best Regards,
    Yang

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know.
    Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

  • Dear Yang,

     

    it is nice of you to reply, i truly appreciate it. The column marked in brackets viz A & B, ie 

    Unit Change (A)Rate Change (B)Final Result (A X B)

    This is derieved from minus the previous day values, which i get from a measure like current minus the previous etc.  This issue is when  i put the date in the slicer the values are correctly depicting, but if i put the same in the matrix, ( Since no date is selected) . It gives any error. 

     

    Thank you in advance for your much need assistance.

     

     

    • Alican_C's avatar
      Alican_C
      Resolver II

      Hi, I believe the measures you used causes it.
      I would handle them with calculated columns as follow:


      1st: 

      Daily Change =
      VAR PreviousDayUnits =
      CALCULATE(
      MAX(TableName[Units]),
      FILTER(
      TableName,
      TableName[Product] = EARLIER(TableName[Product]) &&
      TableName[Date] = EARLIER(TableName[Date]) - 1
      )
      )
      RETURN
      IF(
      ISBLANK(PreviousDayUnits),
      BLANK(),
      TableName[Units] - PreviousDayUnits
      )

      ---

      2nd: 

      Final Result = TableName[Daily Change]*TableName[Rate Change]

      Data table would look like this 

       

      And the matrix will work regardless of slicer selection: