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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Dax - Date Filter

Hello people,

 

I have two measures for a date table, but for different periods:

 

Capture.JPG


Accounting period (mm/21/yyyy  to  mm+1/20/yyyy)
Other Periods


Example:


MonthAccount =  8 (06/21/2020 to 07/20/2020)

MonthAccount =  9  (07/21/2020 to 08/20/2020)

MonthAccount = 10 (08/21/2020 to 09/20/2020)

 

I would like to make a measure that identifies the date period the user has filtered in order to choose the appropriate measure.

 

If the user: Filter dates within the accounting period (mm / 21/2020 to mm + 1/20/2020)
    - measure 1
else 
    - measure 2

 

In short: if the filtered period has only one value for MonthAccount, choose measure 1, if not measure 2.

 

Is it possible to do that?

1 ACCEPTED SOLUTION
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try this:

Measure =
VAR CountMonthAccount_ =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[MonthAccount] ),
        FILTER (
            'Table',
            'Table'[Date] >= MIN ( 'Date'[Date] )
                && 'Table'[Date] <= MAX ( 'Date'[Date] )
        )
    )
RETURN
    IF ( CountMonthAccount_ = 1, [Measure 1], [Measure 2] )
Measure 1 = 1
Measure 2 = 0

v-xuding-msft_0-1601364853097.png

v-xuding-msft_1-1601364876532.png

 

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try this:

Measure =
VAR CountMonthAccount_ =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[MonthAccount] ),
        FILTER (
            'Table',
            'Table'[Date] >= MIN ( 'Date'[Date] )
                && 'Table'[Date] <= MAX ( 'Date'[Date] )
        )
    )
RETURN
    IF ( CountMonthAccount_ = 1, [Measure 1], [Measure 2] )
Measure 1 = 1
Measure 2 = 0

v-xuding-msft_0-1601364853097.png

v-xuding-msft_1-1601364876532.png

 

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.