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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
Latermocdelo
New Member

How to calculate Average with Filters

Good morning,

 

I'm currently Power BI beginer and I try to learn how to use it in the good way.

 

I try to calculate average of error percentage with filters.

 

This is my data tables :

'Table test FX9600' :

Latermocdelo_0-1659512896821.png

 

'Table test LRU1002':

Latermocdelo_1-1659512955256.png

 

And my results table :

Latermocdelo_2-1659512998230.png

 

 

I want to calculate the average of error percentage (column:"Moyenne % erreur") with specific "Session" and "Type de lecteur".

The data is on my two other tables.

I try to solved this problem with the "SWITCH" command, but I think there is a better (faster) way to do this.

 

This is my command which works :

 

Moyenne % Erreur = SWITCH('Param Session'[Type de lecteur],
    "FX9600", SWITCH( [Session], 
                    "Session 0", CALCULATE(AVERAGE('Table test FX9600'[Erreur %]),'Table test FX9600'[Session]="Session 0"),
                    "Session 1", CALCULATE(AVERAGE('Table test FX9600'[Erreur %]),'Table test FX9600'[Session]="Session 1"), 
                    "Session 2",CALCULATE(AVERAGE('Table test FX9600'[Erreur %]),'Table test FX9600'[Session]="Session 2")
                ),
    "LRU1002",  SWITCH( [Session], 
                    "Session 0", CALCULATE(AVERAGE('Table test LRU1002'[Erreur %]),'Table test LRU1002'[Session]="Session 0"),
                    "Session 1", CALCULATE(AVERAGE('Table test LRU1002'[Erreur %]),'Table test LRU1002'[Session]="Session 1"), 
                    "Session 2",CALCULATE(AVERAGE('Table test LRU1002'[Erreur %]),'Table test LRU1002'[Session]="Session 2")
                ),
..........
)

 

 

Someone has any idea to simplify (and automate) this ?

Thanks in advance

Quentin

1 REPLY 1
v-easonf-msft
Community Support
Community Support

Hi, @Latermocdelo 

For the nesting of 'switch' in this measure, I'm afraid it can't be simplified further in DAX.

Best Regards,
Community Support Team _ Eason

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.