Forum Discussion

Novice_YVR's avatar
Novice_YVR
Regular Visitor
2 years ago

Calculating measure for non-existent data

Hi all, 

 

I'm working with Power Pivot but since it's DAX, it should be the same as working with Power BI I hope. 

My problem deals with missing data in my dataset. 

Let's say I have 2 month's worth of data, Dec'23 and Jan'24 and the dataset contains a list of accounts with month end balances. 

My goals are to calculate the total net change in balances, the total change in balance for accounts that increased month over month, and the total change in balance for accounts that decreased month over month. 

For example, let's say there are 3 accounts: A, B & C.

AccountDecJanMoM change
A53-2
B60-6
C7103

 

The total net change is -5, positive change is 3, and negative change is -8.

My previous month balance measure =CALCULATE(SUM(RepricingData[NetBalance]),PARALLELPERIOD(RepricingData[ActualDate],-1,MONTH))

My net change in balance measure =

VAR CurrentBalance = SUMX(RepricingData,RepricingData[NetBalance]) + 0

RETURN CurrentBalance - [Previous Month Balance]

 

The measure in the total row is correct, but when I try to calculate the measures for positive and negative changes, it doesn't work. 

I think the issue is with accounts that had a balance in Dec, but doesn't exist in Jan as per below:

The change from previous month measure should be -736.38 but since there isn't a Jan data point for this account, it's returning a blank. 

 

What would be the best way to correct this? I've tried the following examples and it does not work:

 

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

Thank you. 

7 Replies

  • Hi,

    Do these measures work?

    Measure1 = SUMX(FILTER(VALUES(Data[Account]),[MOM change]<0),[MOM change)

    Measure2 = SUMX(FILTER(VALUES(Data[Account]),[MOM change]>0),[MOM change)

    • Novice_YVR's avatar
      Novice_YVR
      Regular Visitor

      These measures do not work.

      I think the key issue is there's no data existing for account B in Jan. 

      Is there a way to insert a dummy record with the balance at 0 to compensate for this? 

       

      Thanks. 

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Icon for Super User rankSuper User

        Hi,

        Share the dowload link of the PBI file and show the expected result very clearly.