简体   繁体   中英

Filter Data between Start Date and End Date in Power BI

Hey newbie here to DAX:

I have project data with ProjectName, StartDate, EndDate and UsagePercentage.

I want to display usage percentage by time eg how much was the UsagePercentage in Quarter 1 or just a single month.

If I currently use slicers based on Start and End date it does not show me the correct result. 在此处输入图片说明

In the example above If I choose January as my month my Usage should be the one highlighted in yellow since the start date is before January and end date is in January.

I believe I have to create a date slicer like start date <= Date <= End date for this to work. But I am not sure how to create this and apply it to the report. Any help?

You can write a measure where you take the max and min of the values selected by your slicer:

Percentage = 
VAR StartDate = MIN ( Slicer[Date] )
VAR EndDate = MAX ( Slicer[Date] )
RETURN
    CALCULATE (
        SUM ( DataTable[PercentageOfUse] ),
        DataTable[StartDate] <= StartDate,
        DataTable[EndDate] >= EndDate
    )

Your particular situation might be different, but this may point you in the right direction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM