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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
naelske_cronos
Helper III
Helper III

DAX measure - remove filter context but add it again afterwards

Hello,

 

I have a report that I cannot paste so it will be with screenshots and tables. Relationships are selfexplanatory.

 

DIM_Machine

MachineIDMachine

199WAB
299W99
320E44

 

DIM_Department

DepartmentIDDepartment

1V
2B


DIM_Date
DateIDDateDayOfWeekNumberDayOfWeek

202311066/11/20231Monday
202311077/11/20232Tuesday
202311088/11/20233Wednesday
202311099/11/20234Thursday
2023111010/11/20235Friday
2023111111/11/20236Saturday
2023111212/11/20237Sunday
2023111313/11/20231Monday
2023111414/11/20232Tuesday
2023111515/11/20233Wednesday
202311011/11/20233Wednesday
202311022/11/20234Thursday
202311033/11/20235Friday
202311044/11/20236Saturday
202311055/11/20237Sunday

 

FACT_Productivity
ProductivityIDMachineIDDepartmentIDDateIDMachineHours

ProductivityIDMachineIDDepartmentIDDateIDMachineHours

111202311065
221202311066
311202311065
411202311074
511202311073
6212023110610
721202311079
821202311088
921202311089
1011202311087
1132202311068
1232202311098
1332202311108
14322023111014
1521202311092
1611202311093
1711202311101
1811202311134
1921202311135
2021202311139
21112023111310
22112023111411
2321202311142
2321202311143

 

naelske_cronos_0-1733842071015.png

 

I have a measure:

 

_AverageMachineHours =
VAR this_table =
    CALCULATETABLE (
        ADDCOLUMNS (
            SUMMARIZE ( FACT_Productivity, DIM_Date[Date], DIM_Date[DayOfWeekNumber] ),
            "_SumMachineHours", CALCULATE ( SUM ( FACT_Productivity[MachineHours] ) )
        ),
        FILTER (
            DIM_Date,
            YEAR ( [Date] )
                = YEAR ( TODAY() ) - 1
                && NOT ( [DayOfWeekNumber] IN { 6, 7 } )
        )
    )
RETURN
    AVERAGEX (
        this_table,
        [_SumMachineHours]
    )
 
MachineDayOfWeekNumberDayOfWeek_AverageMachineHoursExpectedResult
99W991Monday1527
99WAB1Monday1227
99W992Tuesday716
99WAB2Tuesday916
99W993Wednesday1724
99WAB3Wednesday724
99W994Thursday25
99WAB4Thursday35
99WAB5Friday11

As you can see in the image below, I tried with a remove filters but the problem is that machines are shown that are not related to the selected department.
The result should be the same for every machine based on the selected department but the average should be different per weeknumber (monday till friday).

naelske_cronos_2-1733843754028.png

 

 

If someone could help me out with this one, I'd be grateful.

Thanks!

 

2 REPLIES 2
Anonymous
Not applicable

Hi @naelske_cronos ,

Please correct me if I have misunderstood. You can store the results of your masure values in a virtual table.

 

Measure = 
VAR _table = 
  CALCULATETABLE(SUMMARIZE('Fact_Productivity',Dim_Machine[Machine],Dim_Date[DayOfWeekNumber],[DayOfWeek],"Result",[_AverageMachineHours]),ALL(Dim_Machine[Machine])) 
VAR _result = SUMX(_table,[Result])
RETURN 
IF(ISBLANK(_result),0,_result)

 

vzhouwenmsft_0-1733884932890.png

 

Best Regards,
Wenbin Zhou

 

Hello,

 

I am not getting the correct result. I thought it would be clear with what I wrote.

As in the image below, the department 'V' is selected but only the machines '99W99' and '99WAB' are part of this department (relationship via) 'FACT_Productivity' but as you can see in my table also the machine '20E44' is shown.

 

That is because in my measure from before I added a removefilters on machine and 'removed the filters'. I still want the total average so '27' on monday but only for the machines in department 'V'.

 

_AverageMachineHoursRemoveFilters =
VAR this_table =
    CALCULATETABLE (
        ADDCOLUMNS (
            SUMMARIZE ( FACT_Productivity, DIM_Date[Date], DIM_Date[DayOfWeekNumber] ),
            "_SumMachineHours", CALCULATE ( SUM ( FACT_Productivity[MachineHours] ) )
        ),
        FILTER (
            DIM_Date,
            YEAR ( [Date] )
                = YEAR ( [_SelectedDate] ) - 1
                && NOT ( [DayOfWeekNumber] IN { 6, 7 } )
        ),
        ALLSELECTED ( DIM_Machines[Machine] )
    )
RETURN
    AVERAGEX (
        this_table,
        [_SumMachineHours]
    )
 

naelske_cronos_0-1733899563318.png

 

 

 

Kind regards

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.

Top Solution Authors