cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Terence2021
Frequent Visitor

Calculating totals without row context limiting data

I've been attempting to find a solution for this for a while now and haven't been able to.

 

I'm trying to get the values for the Equipment_Days2 column to read:

14    associated with equipment_qty of 4                 (Only including days with qty 4)

17    associated with equipment_qty of 1                 (Including days with qty 4, 2 or 1)

15    associated with equipment_qty of 2                 (Including days with qty 2 or 4)

 

 

Terence2021_0-1636670022047.png

 

Underlying Data

Terence2021_1-1636670109851.png

 

The ALL filter functionality below does not appear to be stripping away the qty row filter in the calculation so that all of the rows associated with the equipment are included in the sum for DaysValue.  How can this be done?

 

Equipment_Days2 = Calculate(SUM(CalculatedDaysTable[DaysValue]),FILTER( ALL(CalculatedDaysTable), CalculatedDaysTable[job_no] == earlier(CalculatedDaysTable[job_no]) && CalculatedDaysTable[Equipment No and Description] == Earlier(CalculatedDaysTable[Equipment No and Description]) && CalculatedDaysTable[date_ASCII] == Earlier(CalculatedDaysTable[date_ASCII]) && CalculatedDaysTable[equipment_uom] == "Daily" && CalculatedDaysTable[equipment_qty] <= Earlier(CalculatedDaysTable[equipment_qty])))
1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

This might get you a bit closer.

Equipment_Days2 =
VAR CurrQty = CalculatedDaysTable[equipment_qty]
RETURN
    CALCULATE (
        SUM ( CalculatedDaysTable[DaysValue] ),
        CalculatedDaysTable[equipment_qty] <= CurrQty,
        CalculatedDaysTable[equipment_uom] = "Daily"
    )

 

You used ALL on the entire table, which removes the context from all columns. I'd recommend only using it for specific columns unless you really do want to get rid of all the filtering.

View solution in original post

4 REPLIES 4
Terence2021
Frequent Visitor

Unfortunately this results in the exact same output as I've been continuously getting, with the additions not being cumulative.

 

This formulation did work once it was converted to a measure.

 

Equipment_Days = VAR CurrQty = max(CalculatedDaysTable[equipment_qty])
RETURN
CALCULATE (
SUM (CalculatedDaysTable[DaysValue]),
CalculatedDaysTable[equipment_qty] >= CurrQty &&
CalculatedDaysTable[equipment_uom] = "Daily"
)
 
Thank you for pointing me in the right direction.

If you're trying to do this as a calculated column, then you have to get the context exactly right. Either remove filters on all the columns you don't want or remove all filters except for a specific set of columns you do want.

 

I can't tell what all columns you have in your table, so I can't do much more than an educated stab in the dark and you'll have to adjust it to fit your particular table.

AlexisOlson
Super User
Super User

This might get you a bit closer.

Equipment_Days2 =
VAR CurrQty = CalculatedDaysTable[equipment_qty]
RETURN
    CALCULATE (
        SUM ( CalculatedDaysTable[DaysValue] ),
        CalculatedDaysTable[equipment_qty] <= CurrQty,
        CalculatedDaysTable[equipment_uom] = "Daily"
    )

 

You used ALL on the entire table, which removes the context from all columns. I'd recommend only using it for specific columns unless you really do want to get rid of all the filtering.

Helpful resources

Announcements
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Show episode 9

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 26

New Date - Check it Out!

Mark your calendars and join us on Thursday, October 6 at 11a PDT for a great session with Ted Pattison!

Top Solution Authors
Top Kudoed Authors