DAX Multiple Filters Across Multiple Tables

Veritan

Active Member
Joined
Jun 21, 2016
Messages
387
Office Version
  1. 365
I have a Power BI Desktop file with 2 tables in it, Exception_Report (my primary fact table) and BusinessCalendar (which is my designated Date Table where the field RealDate is the unique date column). The two are related with a 1 to Many relationship where BusinessCalendar[RealDate] = Exception_Report[GL Date]. I am attempting to get a distinct count of the Exception_Report[Batch Number] field based on 2 criteria. First, I only want to count batches with a GL date in the previous calendar month. Second, I only want to count batches where the field Exception_Report[Status] is not null.

I can get DAX to work fine with either one of the 2 criteria, but I'm struggling to include both of them. I'm hoping that someone is able to help me combine the 2 measures (specifically the filtering portion) in order to return the correct result that accounts for both filters simultaneously. Thank you in advance!

Excel Formula:
BatchCount =
CALCULATE(
    DISTINCTCOUNT(Exception_Report[Batch Number]),
    DATESBETWEEN(
        'BusinessCalendar'[RealDate],
        EOMONTH(TODAY(), -2) + 1,
        EOMONTH(TODAY(), -1)
    )
)

Excel Formula:
BatchCount =
CALCULATE(
    DISTINCTCOUNT(Exception_Report[Batch Number]),
    FILTER(
        'Exception_Report',
        'Exception_Report'[Status] <> BLANK()
    )
)
 
How about:

Excel Formula:
BatchCount =
CALCULATE(
    DISTINCTCOUNT(Exception_Report[Batch Number]),
    FILTER(
        Exception_Report,
        Exception_Report[Status] <> BLANK()
    ),
    DATESBETWEEN(
        'BusinessCalendar'[RealDate],
        EOMONTH(TODAY(), -2) + 1,
        EOMONTH(TODAY(), -1)
    )
)
 
Upvote 0
Solution
I really cannot believe that I didn't think of that. Somehow I got stuck on thinking that you could only have 1 filter argument in the CALCULATE function. Thank you for helping me get my head on straight!
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top