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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Dje33
New Member

How to calculate a sum with part of page filters + 1 formula filter

Good morning,

I need a little help.

I created a report with 3 filters (date / workshop / machine). file attached
My table contains quantities of parts produced by machine and date  (each machine is in a workshop, there are several workshops)

I want to calculate a sum of production quantity and display it in the report with the following filters
- remove the date filter (report page filter)
- keep the workshop report filter (report page filter)
- keep the machine report filter (report page filter)
- add a week filter (formula filter) ("week" data present in the table)

I tried several things without success. I always have either all the filters of the active report or none...

as

 

the result obtained shows that either 

z_QteProdSem =
VAR ActualWeek = MAXX(all(VtSortiesV2),VtSortiesV2[y_AnSem])
VAR ActualWeekPeriode = FILTER(ALLEXCEPT(VtSortiesV2,VtSortiesV2[y_atelier'],VtSortiesV2[Machine]),VtSortiesV2[y_AnSem]=ActualWeek)
RETURN
SUMX(ActualWeekPeriode, VtSortiesV2[QuantiteTotale])

 

or

z_QtéSem2 = sumx(FILTER(ALLEXCEPT(Feuil1,Feuil1[Atelier'],Feuil1[Machine]),Feuil1[semaine]=24),Feuil1[QuantiteTotale])

 

the result obtained shows that either all the filters of the active report or none filter...

Can you help me?

 

4 REPLIES 4
Dje33
New Member

Hello Sahir,

 

I found the solution :

I use REMOVEFILTERS and SELECTDVALUE in a formula CALCULATE with variable

 

VAR FYN1Select=LEFT(SELECTEDVALUE(calendrier[FYannée]),2)&(RIGHT(SELECTEDVALUE(calendrier[FYannée]),2)-1)
RETURN
CALCULATE(SUM(VtSortiesV2[QuantiteTotale]),
 REMOVEFILTERS(calendrier[FYannée]),
 calendrier[FYannée]=FYN1Select)/
CALCULATE(
    SUMX(vevenements,vevenements[Duree]*vevenements[EvenementPLC]*vevenements[y_cadenceM]*60),
    REMOVEFILTERS(calendrier[FYannée]),
    codesEvt[TRS]="oui",
    vevenements[y_FY]=FYN1Select)

 

Dje33
New Member

Many thanks Sahir,

Your answer is so simple!

I thought too complicated, I also think I succeeded with variables and CALCULATE

Sahir_Maharaj
Super User
Super User

Hello @Dje33,

 

To achieve this, you can use a combination of measures and the ALL function to control the context of the calculation:

 

1. Create a Measure for Week Filter

 

SelectedWeek = MAX('VtSortiesV2'[y_AnSem])

 

2. Create a Measure for Calculating Sum

 

z_QteProdSem = 
VAR SelectedWeek = [SelectedWeek]  -- Use the measure you created in step 1
RETURN
SUMX(
    FILTER(
        ALL('VtSortiesV2'),
        'VtSortiesV2'[y_AnSem] = SelectedWeek &&
        'VtSortiesV2'[y_atelier'] = SELECTEDVALUE('VtSortiesV2'[y_atelier']) &&
        'VtSortiesV2'[Machine] = SELECTEDVALUE('VtSortiesV2'[Machine])
    ),
    'VtSortiesV2'[QuantiteTotale]
)

 

Should you require further assistance, please do not hesitate to reach out to me.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Hello Sahir,

 

In fact there is a problem.

The result is empty. I have the impression that it does not accept to have several machines selected

VtSortiesV2'[Machine] = SELECTEDVALUE('VtSortiesV2'[Machine]) 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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