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
emanuela
New Member

cumulate formula in power bi

HI all,

i try to wokr on the cumulate formula but even if the formula seems to be correct the results make no sense. 

I have a dashboard with 2 filters fiels and 2 tables: the first just a regular sum and the second with the cumulate quantity per month using this formula "calculate(sum(CSV[OC QTY]),FILTER(ALL(csv),CSV[PIVOT DATE]<=max(CSV[PIVOT DATE])))".

As you can see the results make no sense.

 

emanuela_0-1710755075205.png

can you help me on fix this?

thank yo so much

emanuela

1 ACCEPTED SOLUTION
v-kongfanf-msft
Community Support
Community Support

Hi @emanuela ,

 

According to your description, the all function was used in your formula and it filtered out the filter criteria of the two external filters, resulting in incorrect results. I tried to modify your formula:

Cumulative Quantity = 
CALCULATE(
    SUM(CSV[OC QTY]),
    FILTER(
        ALL(CSV),
        CSV[PIVOT DATE] <= MAX(CSV[PIVOT DATE]) && 
        YEAR(CSV[PIVOT DATE]) = SELECTEDVALUE(DateTable[Year]) && 
        MONTH(CSV[PIVOT DATE]) = SELECTEDVALUE(DateTable[Month])
    )
)

 

If the problem persists, please provide relevant test data and screenshot information.

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
v-kongfanf-msft
Community Support
Community Support

Hi @emanuela ,

 

According to your description, the all function was used in your formula and it filtered out the filter criteria of the two external filters, resulting in incorrect results. I tried to modify your formula:

Cumulative Quantity = 
CALCULATE(
    SUM(CSV[OC QTY]),
    FILTER(
        ALL(CSV),
        CSV[PIVOT DATE] <= MAX(CSV[PIVOT DATE]) && 
        YEAR(CSV[PIVOT DATE]) = SELECTEDVALUE(DateTable[Year]) && 
        MONTH(CSV[PIVOT DATE]) = SELECTEDVALUE(DateTable[Month])
    )
)

 

If the problem persists, please provide relevant test data and screenshot information.

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi Adam,

thank you but still is not working. it shows me this error "A single value for variaton 'Year' for column 'Date' in table 'calendario' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."...

how can i fix it?

 

best,

emanuela

Uzi2019
Super User
Super User

Hi @emanuela 
You can try this formula. I hope this gives you correct answer

12 month Rollback = CALCULATE(SUM(Table[Clicks]),DATESINPERIOD('Calendar'[Date],Max('Calendar'[Date]),-12,MONTH))

 

I hope I answered your question!

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

hi thank you but it's not working, here waht i got (first just regular sum, second table usign your formula):

emanuela_0-1710758459191.png

thanks for clarify

 

 

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.