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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Dax for displaying only dates from selected range on date slicer

Hi Experts,

 

I need help in showing dates only from selected range on the date slicer. 

For example in the following snapshot of my fortnightly report, I expect the report to display only the records highlighted in yellow( as the Period selected is between 8/4/2019 to 5/5/2019)

 

fort_capture.PNG

 

Thanks in advance,

Meena

1 ACCEPTED SOLUTION

Just check if can create two more variables using MINX, MAXX - https://docs.microsoft.com/en-us/dax/minx-function-dax,

Use the filter example and find the min week start date when min week start date > Start_date of the slicer. Same way Max

 

 

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User
Anonymous
Not applicable

Thanks @EVEAdmin  and @amitchandak for your response.

Though the links are very useful, but i can't figure out how can i implement the solution in my scenario.

So, basically I have a table called 'Emp', that I get employees fortnightly payments from. I created a non related table called 'Dim week ending' with DAX- ALLSELECTED(Emp[Period_end_date]. Then I created a measure to calculate fortnightly payments as following:

Total fortnightly payment =

VAR _lastdate =

    CALCULATE (

        MAX ( 'Dim week ending'[Period End Date] ),

        FILTER (

            ALLSELECTED ( 'Dim week ending'[Period End Date] ),

           'Dim week ending'[Period End Date] < MAX ( 'Dim week ending'[Period End Date])

        )

    )

RETURN

    IF (

        MAX ( 'Dim week ending'[Period End Date] ) <= MAX ( ‘Emp’[Period End Date]),

        CALCULATE (

            SUM ( ‘Emp’ [Amount] ),

            FILTER (

                ALL (‘Emp’ [Period End Date] ),

                ‘Emp’ [Period End Date] <= MAX ( 'Dim week ending'[Period End Date])

                    && ‘Emp’ [Period End Date]> _lastdate

            )

        )

    )

 

I would highly appreciate if you can tell me where to include the logic for displaying only the fortnightly periods selected from the date range slicer.

 

Thanks,

Meena

The table shown in the first example may work like this

 

Measure1 =
var MIN_SLICER_DATE = MIn(Silcer(DATE))
var MAX_SLICER_DATE = MAX(Silcer(DATE))
CALCULATE (

SUM ( ‘Emp’ [Amount] ),

‘Emp’ [Period End Date] >= MIN_SLICER_DATE

&& ‘Emp’ [Period End Date] <=MAX_SLICER_DATE

)

But if the weekend date need to be calculated then more logic is needed 

 

Just check if can create two more variables using MINX, MAXX - https://docs.microsoft.com/en-us/dax/minx-function-dax,

Use the filter example and find the min week start date when min week start date > Start_date of the slicer. Same way Max

 

 

Anonymous
Not applicable

thanks @amitchandak , I don't want to disrupt my current logic of fortnight end date. Any way I can include the min & max date seprately? or perhaps merge it with existing logic?

EVEAdmin
Helper V
Helper V

I guess this tutorial will be helpful

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.