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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
ankurbajaj07
Helper I
Helper I

Summing up of manhours based on slicer range selection corresponding to filtered jobs

In power bi, I need a measure for dax code where when user selects date range from a slicer (calender table), jobs (only the instances where it lies in the selected calender date range) and corresponding manhours (only for the selected calender date range) from my table Bi_ alloceffort_data gets displayed where the REVDATE in same table falls between the user selected range.

 

 I tried the follwomg codes:

 

1. 

Selected_Manhours :=
VAR SelectedMinDate = MIN('Calendar'[Date])
VAR SelectedMaxDate = MAX('Calendar'[Date])

RETURN
CALCULATE(
SUM(Bi_alloceffort_data[Manhours]),
Bi_alloceffort_data[REVDATE] >= SelectedMinDate &&
Bi_alloceffort_data[REVDATE] <= SelectedMaxDate
)

 

2.

Selected_Manhours :=
VAR SelectedMinDate = MIN('Calendar'[Date])
VAR SelectedMaxDate = MAX('Calendar'[Date])

RETURN
SUMX(
FILTER(
Bi_alloceffort_data,
Bi_alloceffort_data[REVDATE] >= SelectedMinDate &&
Bi_alloceffort_data[REVDATE] <= SelectedMaxDate
),
Bi_alloceffort_data[Manhours]
)

 

3. 

Selected_Manhours :=
VAR SelectedMinDate = MIN('Calendar'[Date])
VAR SelectedMaxDate = MAX('Calendar'[Date])

RETURN
CALCULATE(
SUM(Bi_alloceffort_data[Manhours]),
KEEPFILTERS(
Bi_alloceffort_data[REVDATE] >= SelectedMinDate &&
Bi_alloceffort_data[REVDATE] <= SelectedMaxDate
))

 

But all the solutions are selecting the job based on slcier filter and then summing all the manhours (even ehen they are outside the slicer range) for the all job instances.

 

I need manhours only for the instance where jobs and manhours are within the selected slicer range.

 

Pls help

2 ACCEPTED SOLUTIONS
techies
Solution Sage
Solution Sage

Hi @ankurbajaj07 please check this 

 

Selected Manhours =
CALCULATE (
    SUM ( Bi_alloceffort_data[Manhours] ),
    FILTER (
        Bi_alloceffort_data,
        Bi_alloceffort_data[REVDATE] >= MIN ( Calendar[Date] )
            && Bi_alloceffort_data[REVDATE] <= MAX ( Calendar[Date] )
    )
)
 
techies_0-1743770289483.png

 

― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

View solution in original post

v-tsaipranay
Community Support
Community Support

Hi @ankurbajaj07 ,

Thanks for reaching out to the Microsoft Fabric Community.

 

The solution shared by @techies  is technically accurate. The DAX measure below correctly filters the Bi_alloceffort_data table to include only records where REVDATE falls within the selected date range from the calendar slicer:

Selected Manhours =
CALCULATE (
    SUM ( Bi_alloceffort_data[Manhours] ),
    FILTER (
        Bi_alloceffort_data,
        Bi_alloceffort_data[REVDATE] >= MIN ( Calendar[Date] ) &&
        Bi_alloceffort_data[REVDATE] <= MAX ( Calendar[Date] )
    )
)

This approach ensures that only the relevant job instances and corresponding manhours within the selected date range are included in the calculation.

 

I hope this will resolve your issue, if you need any further assistance, feel free to reach out.

If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.

Thankyou.

View solution in original post

7 REPLIES 7
v-tsaipranay
Community Support
Community Support

Hi @ankurbajaj07 ,

 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

 

Thank you.

v-tsaipranay
Community Support
Community Support

Hi @ankurbajaj07 ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


Thank you.

v-tsaipranay
Community Support
Community Support

Hi @ankurbajaj07 ,

Thanks for reaching out to the Microsoft Fabric Community.

 

The solution shared by @techies  is technically accurate. The DAX measure below correctly filters the Bi_alloceffort_data table to include only records where REVDATE falls within the selected date range from the calendar slicer:

Selected Manhours =
CALCULATE (
    SUM ( Bi_alloceffort_data[Manhours] ),
    FILTER (
        Bi_alloceffort_data,
        Bi_alloceffort_data[REVDATE] >= MIN ( Calendar[Date] ) &&
        Bi_alloceffort_data[REVDATE] <= MAX ( Calendar[Date] )
    )
)

This approach ensures that only the relevant job instances and corresponding manhours within the selected date range are included in the calculation.

 

I hope this will resolve your issue, if you need any further assistance, feel free to reach out.

If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.

Thankyou.

Hi @ankurbajaj07 ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


Thank you.

techies
Solution Sage
Solution Sage

Hi @ankurbajaj07 please check this 

 

Selected Manhours =
CALCULATE (
    SUM ( Bi_alloceffort_data[Manhours] ),
    FILTER (
        Bi_alloceffort_data,
        Bi_alloceffort_data[REVDATE] >= MIN ( Calendar[Date] )
            && Bi_alloceffort_data[REVDATE] <= MAX ( Calendar[Date] )
    )
)
 
techies_0-1743770289483.png

 

― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978
bhanu_gautam
Super User
Super User

@ankurbajaj07 , Try using 

dax
Selected_Manhours :=
VAR SelectedMinDate = MIN('Calendar'[Date])
VAR SelectedMaxDate = MAX('Calendar'[Date])

RETURN
SUMX(
FILTER(
Bi_alloceffort_data,
Bi_alloceffort_data[REVDATE] >= SelectedMinDate &&
Bi_alloceffort_data[REVDATE] <= SelectedMaxDate
),
Bi_alloceffort_data[Manhours]
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Its the same as option 2 which i tried but is not filtering manhours based on seletcion. When i am using this measure in table along with jobs, only job are getting filtered in line with slcier and then manhours are getting summed up against that job for all instances of the job removing the slicer criteria.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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