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
tragonneau
Frequent Visitor

Problem with cumulation total when adding filters

Hello,

 

I have the following table :

StockTableStockTable

I have created this measure to have the cumulative total of the Qty :

qty_cumul = 
CALCULATE( SUM(Stock[Qty]); FILTER( ALL(Stock[date]); Stock[date] <= MAX(Stock[date]) ) )

 

It works as I want. When I want to see the evolution of the cumulative total for specific entities (let's say ENT_1 and ENT_2), it still works well. 

 

HOWEVER i have a problem when I add a visual filter to see the evolution of the total for a specific period. The result is not the sum of the cumulative quantity of ENT_1 and ENT_2 (whereas it is when i don't use the filter on the date).

 

cumulativeTotalProblemWithDateFilter.png

 

I realised this graph is displaying alternatively the cumulative total of ENT_1 and ENT_2 which is not what I want.

When I added the filter on the date i expected my bottom chart to be a "zoom in" of the top chart.

 

I don't understand why it doesn't work as I want. I feel like I am missing something.

Can you help me please.

 

I am working in DirectQuery mode but to explain my issue i created a custom table.

Here the file i used to do the screenshots:

https://www.dropbox.com/s/sekh8g8ht03ibbs/StockCumulativeTotal.pbix?dl=0

1 ACCEPTED SOLUTION
blopez11
Resident Rockstar
Resident Rockstar

Something similar to the following worked for me, but I needed a date table, where on my visual I used the month field from the date table for the axis, and I had a slicer that used year from the date table.  However, I haven't tried in DirectQuery mode

 

Cumulative Quantity :=
CALCULATE (
    SUM ( Transactions[Quantity] ),
    FILTER (
        ALL ( 'Date' ),
        'Date'[Date] <= MAX ( 'Date'[Date] )
    )
)

 

View solution in original post

3 REPLIES 3
v-qiuyu-msft
Community Support
Community Support

Hi @tragonneau,

 

From the .PBIX file you provided, you have added filter for the bottom line chart in Visual Level Filter property, which only apply to the bottom line chart. This filter setting will not apply for other line chart or table visual. So the data for the same date display as different values in those two line charts. See: Add a filter to a Power BI report (in Editing view).

 

a2.PNG

 

In your scenario, please remove visual level filter, add the same filter on page level filter, this filter will apply for all visuals in this report page. Also you need to apply the filter like below:

 

qty_cumul = CALCULATE(
    SUM(Stock[Qty]),
    FILTER(
     ALLSELECTED(Stock),
     Stock[date] <= MAX(Stock[date])
    )
)

 

Please download and run the attached .PBIX file to see if it meet your requirement.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@blopez11

Thanks, it works well with the DateTable. I don't know why i didn't use it.

 

@v-qiuyu-msft

Thanks, but it's not what i wanted to do.

My explanations were confusing, i'm sorry.

Maybe it will make more sense with the following screenshot.

I wanted to see the values for a shorter period : the top side chart represents the values in the red rectangle.

solutionWanted.png

 

blopez11
Resident Rockstar
Resident Rockstar

Something similar to the following worked for me, but I needed a date table, where on my visual I used the month field from the date table for the axis, and I had a slicer that used year from the date table.  However, I haven't tried in DirectQuery mode

 

Cumulative Quantity :=
CALCULATE (
    SUM ( Transactions[Quantity] ),
    FILTER (
        ALL ( 'Date' ),
        'Date'[Date] <= MAX ( 'Date'[Date] )
    )
)

 

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.