Forum Discussion

Amos_Lim's avatar
Amos_Lim
Resolver I
2 years ago

Find the different before sum up

I have a measure that pwerform sum up as shown.

.
I would like to have additional 2 measures:-

1) to calculate the difference between the values of these two dates before summing them up. i.e. this month values - last month values then perform the sum up.

2) to calculate how many values that was <>0 (<0 or >0) after finding the dfferent.

 

How can I achieve this? Thanks.

 

 

 

Sum QR-A = 
VAR Selected_Date = MAX(CalendarDate[Date])
VAR Previous_Date = CALCULATE(MAX(CalendarDate[Date]), PREVIOUSMONTH(CalendarDate[Date]))

VAR Sum_A = CALCULATE(
                    SUM('Raw Data'[Gradient-A]), 
                    FILTER(
                        'Raw Data',
                        NOT(
                            (
                                YEAR('Raw Data'[P-Date]) = YEAR(Selected_Date) && 
                                MONTH('Raw Data'[P-Date]) = MONTH(Selected_Date)
                            ) ||
                            (
                                YEAR('Raw Data'[R-Date]) = YEAR(Selected_Date) && 
                                MONTH('Raw Data'[R-Date]) = MONTH(Selected_Date)
                            ) ||
                            (
                                YEAR('Raw Data'[P-Date]) = YEAR(Previous_Date) && 
                                MONTH('Raw Data'[P-Date]) = MONTH(Previous_Date)
                            ) ||
                            (
                                YEAR('Raw Data'[R-Date]) = YEAR(Previous_Date) && 
                                MONTH('Raw Data'[R-Date]) = MONTH(Previous_Date)
                            )
                        )
                    )
                )

RETURN Sum_A + 0

 

 

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Amos_Lim 

     

    To help you better, please provide some dummy data as well as the expected results. Preferably in tabular form.

     

    Regards,

    Nono Chen

    • Amos_Lim's avatar
      Amos_Lim
      Resolver I

      Please find the attached sample file.

      The raw data sheet was imported into Power BI, and the expected result sheet contains my manual calculations.

      The latest data within the same month was not included. For example, if a same A-set and C-No occur one or more times within the same month, only the data from the last date is used. Additionally, P-Date and R-Date data were excluded.

       

      sample file

       

       

      • Amos_Lim's avatar
        Amos_Lim
        Resolver I

        Not sure if this is achievable in PBI or power query?