Forum Discussion

srinivas258's avatar
srinivas258
Icon for Helper I rankHelper I
6 years ago
Solved

Cumulative total on two tables

Hello all,

Below are the two tables I have in my model (Fact and Dim). The join between the two tables is based on ID.

 

Fact Table 
IDTotalStop
10031
20052
30043
40014

 

Dim 
IDName
100AA
200BB
300CC
400DD

 

Output :

 

Output   
StopNameTotalRunning Total
1AA33
2BB58
3CC412
4DD113

 

I got the running total working using the below formula but it works as long as I have columns from Fact table ONLY. As soon as I place column from Dim table (i.e Name) the running total stops working and it displays the actual totals instead.

RT = CALCULATE(SUM(Table[Fact Table]),filter(allselected(Fact Table),Fact Table[Stop] <=max(Fact Table[Stop])))

I think I need to extend my DAX further and add Dim table to above formula but I am struck how this can be done. Can anyone please help on this. Thank you.

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi camargos88 ,

    Based on the data and formula you currently provide, it can return the correct value. Could you please provide some screen shots about the below scenario? We need this information to see if we missed anything...


    As soon as I place column from Dim table (i.e Name) the running total stops working and it displays the actual totals instead.

    Best Regards

    Rena

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi camargos88 ,

    Based on the data and formula you currently provide, it can return the correct value. Could you please provide some screen shots about the below scenario? We need this information to see if we missed anything...


    As soon as I place column from Dim table (i.e Name) the running total stops working and it displays the actual totals instead.

    Best Regards

    Rena

    • srinivas258's avatar
      srinivas258
      Icon for Helper I rankHelper I

      Hi Anonymous  and camargos88 

       

      Thanks for you inputs. Actually upon investigation found that the join between fact and dim is many to many which is causing the issue. There are some duplicates in dim table which we removed from backend table and the formula that I posted worked without any issues.  Thanks again it was backend table issue at the end.