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

Running Stock Levels - remove row context

Hello,

 

I have an issue with a running total measure whereby the value displayed on the maxtrix visual for a row conflicts with the filter applied to the running total in the filters pane, e.g:

- running total for a product on a given date = -1

- set filter panel on the visual to show items where running total < 0

- the correct row for the product/date appears but the running total = 4

 

the rows are filtered correctly but when the running total is evaluated for each row, it only considers the rows returned by the filter context.

 

here is the running total measure :

 

Running Total =
CALCULATE(
    [Stock Movement],
ALLSELECTED('Dim Date'),
    FILTER(
        ALLSELECTED('Dim Date'[Date]),
        'Dim Date'[Date] <= MAX('Dim Date'[Date])
    )
) + [Stock Quantity]
 
What can I add to the measure to remove this behaviour?
1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

It may be an error caused by the relationship between the tables, and no further testing can be done temporarily.

 

Refer to the links below to provide corresponding information. How to Get Your Question Answered Quickly - Microsoft Power BI Community


Best Regards,
Henry

 

View solution in original post

4 REPLIES 4
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

Can you provide some test data (delete sensitive information), I will answer further. Looking forward to your reply.


Best Regards,
Henry

 

lbendlin
Super User
Super User

Your measure seems to have extra dangly bits, and can be streamlined.

 

Running Total =
CALCULATE(
    [Stock Movement],
ALLSELECTED('Dim Date'),
'Dim Date'[Date] <= MAX('Dim Date'[Date])
) + [Stock Quantity]

 

However, your MAX function is evaluated in the row context, so it is likely not doing what you want it to do.  Most likely you want to have a different calculation for that value (in a variable)  and then use the variable in the filter.

Running Total =
var m=CALCULATE(max('Dim Date'[Date]),<some filter>)
Return CALCULATE(
    [Stock Movement],
ALLSELECTED('Dim Date'),
'Dim Date'[Date] <= m
    )
) + [Stock Quantity]
Anonymous
Not applicable

Hi @lbendlin 

 

Thanks for the reposonse. Yup some dangly bits, they were products of previous attempts, thanks for suggesting a refined version though.

 

How can I filter the max date whereby the measure uses the max date for each row of the table/matrix but still adds all rows previous to the date? 

v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

It may be an error caused by the relationship between the tables, and no further testing can be done temporarily.

 

Refer to the links below to provide corresponding information. How to Get Your Question Answered Quickly - Microsoft Power BI Community


Best Regards,
Henry

 

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.

Top Solution Authors