Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Relationship influences outcome of calculated column

Hi guys,

 

I'm still struggling to understand the inner workings of DAX, and I've come across a situation that my mind cant seem to process.

 

A while ago I posted this problem:

 

The dataset is like this:

dayprogram weekSales
01/01/2017AW01400
02/01/2017AW01450
03/01/2017AW01500
04/01/2017AW01600
05/01/2017AW01450
06/01/2017AW01550
07/01/2017AW01560
08/01/2017AW02400
09/01/2017AW02450
10/01/2017AW02500
11/01/2017AW02600
12/01/2017AW02450
13/01/2017AW02550
14/01/2017AW02560

 

What I want is a fourth column (measure/column?) that gives me the cumulative sum of these values, but partitioned by program week and ordered by date.

 

The resulting table should look like this:

 

dayprogram weekSalesCumulative Weekly
01/01/2017AW01400400
02/01/2017AW01450850
03/01/2017AW015001350
04/01/2017AW016001950
05/01/2017AW014502400
06/01/2017AW015502950
07/01/2017AW015603510
08/01/2017AW02200200
09/01/2017AW02450650
10/01/2017AW025001150
11/01/2017AW026001750
12/01/2017AW024502200
13/01/2017AW025502750
14/01/2017AW025603310

 

 

The answer was this:

CumulativeWeekly =
CALCULATE (
    SUM ( Table1[Sales] ),
    FILTER (
        ALLEXCEPT ( Table1, Table1[program week] ),
        Table1[day] <= EARLIER ( Table1[day] )
    )
)

 

Which works really well. However, this stops working as soon as there is a relationship in my original data between the date column and a date table.

 

Can someone explain why this is happening? I'm not referring to that date table in my formula, why does it have such a big impact on my calculated column? Whats the solution?

 

Thanks a lot guys, I know its a long read 🙂

 

Jaap 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous

 

Try this method:

 

Running total of Sales = CALCULATE(SUM('Running total based on category'[Sales]);FILTER(ALL('Running total based on category');'Running total based on category'[Day] <= MAX ( 'TimeDim'[Date] ));VALUES('Running total based on category'[Program week]))

 

It has the VALUES-formula, which returns the unique values from a column.

 

Let me know if this works. It should work with your time dimension. I'll also gladly elaborate, if you want me to.

View solution in original post

10 REPLIES 10

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.