Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Measure not ignoring filters?

I need to count ID's from my Retail table, but for weird reasons, I can't have a relationship from my Dates table to my Retail table.

 

I have the measure below which correctly picks up the min and max date integers from my Date table and stores them as variables. I want to then filter my retail table by those store variables while also ignoring any filters on the page (which are from the Date table). Am I doing something wrong with the below measure?

 

Total YTD History = var mindate = CALCULATE(MIN('Dates'[dateInt]),ALL('Dates'[Period]),ALL('Dates'[Week Number])) var maxdate = CALCULATE(MAX('Dates'[dateInt]))
return CALCULATE(DISTINCTCOUNT('Retail'[ID]),ALL('Dates'[Period]),ALL('Dates'[Week Number]),FILTER('Retail','Retail'[dateInt]<= maxdate && 'Retail'[dateInt]>=mindate))

 

4 Replies

  • az38's avatar
    az38
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 

    I think this part 

     CALCULATE(DISTINCTCOUNT('Retail'[ID]),ALL('Dates'[Period]),ALL('Dates'[Week Number]),FILTER('Retail','Retail'[dateInt]<= maxdate && 'Retail'[dateInt]>=mindate))

    could be rewrited as

     CALCULATE(DISTINCTCOUNT('Retail'[ID]),
    FILTER(ALL('Retail'),'Retail'[dateInt]<= maxdate && 'Retail'[dateInt]>=mindate))
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the reply az38 . Using your suggestion gives me the same repeating value? Something off with a relationship? I guess I have some columns from a different table then Retail on my matrix visual. I pretty much just want to ignore any filters coming from my Date table.

       

      So I have filters on my page from my Date table. I want to ignore those filters, but use them in my measure to determine the min and max dates. Then filter the Retail table by those min and max dates.

      • az38's avatar
        az38
        Icon for Community Champion rankCommunity Champion

        Anonymous 

        you find min and max dates from date table with variables.

        then you used it for filter fact table. what context do you want to use further?

        could you give an example: data sample and desired output based on this sample?