'Power BI Calculate distinct impacting when I use filter

I made a measure that is as follows:

wo = CALCULATE(
DISTINCTCOUNT('Table1'[won]),
ALLEXCEPT(Table1, 'Table1'[flag]),
ALLEXCEPT(Calendar,Calendar[End of Week]),
FILTER(Table1,[flag]="Y")
)

I want the total amount of items in 'won' column with the flag = 'Y'. But when I use one date range filter [End of Week] I had problem because my total amount keeps changing and shouldn't change, I want the total of my entire table regardless of date.

This measure works without 'Y' flag, but it's not what I need:

wo= CALCULATE(
DISTINCTCOUNT('Table1'[wo]),
ALL(Calendar)
)

Could you please help me how to adjust this measure?



Solution 1:[1]

Solved using this DAX CODE:

wo= CALCULATE(
    DISTINCTCOUNT('Table1'[won]),
    FILTER(ALL(Table1),[flag]="Y")
)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeremy Caney