Reply
konradjonsson
Helper II
Helper II
Partially syndicated - Outbound

How to get average networkdays

Hi.

 

I have an issue with how my measure is aggregated in a hierarchy.

 

I have created a measure that gives me the working days per country.

Workdays V2 measure.png

 

When presenting this in e.g. a matrix visual, the working days render correctly per country.

Workdays - country matrix 2211.png

'Workdays' in picture above is using the regular networkdays-function:

Networkdays, Nov 2022: 22

(no holidays considered)

 

The problem appears when the countries are summarized in a regional hierarchy.

-it seems like that, on regional level, the working days are reduced with all unique holiday dates

 

The table having the holidays looks like follows

Global workdays table.png

 

RESULT – WHICH IS “INCORRECT” ON REGION LEVEL

AMR: 17 (Nov 2, 11, 15, 24, 25)

-US: 19 (11, 24, 25)

-CAN: 21 (11)

-BRZ: 20 (2, 15)

 

WHAT I WOULD LIKE TO ACHIEVE

I would like the result to be the average of the included countries.

In the example above, AMR should then be 20 ((19 + 21 + 20) / 3).

1 ACCEPTED SOLUTION
avatar user
Anonymous
Not applicable

Syndicated - Outbound

Hi  @konradjonsson ,

I created some data:

vyangliumsft_0-1671780620218.png

You can use the composition IF + ISINSCOPE() to implement the calculation of the different levels of the matrix.

IF function (DAX) - DAX | Microsoft Learn

ISINSCOPE function (DAX) - DAX | Microsoft Learn

Here are the steps you can follow:

1. Create measure.

Here we have [Group2] and [Group3] to calculate, the remaining two levels can be written directly into the formula to calculate the corresponding level, here Group1 = 1, Total = 0

Flag =
IF(
ISINSCOPE('Table'[Group3]),[Workdays V2],
IF(     ISINSCOPE('Table'[Group2])&&NOT(ISINSCOPE('Table'[Group3])),AVERAGEX(FILTER(ALL('Table'),'Table'[Group2]=MAX('Table'[Group2])),[Workdays V2]),
     IF(   ISINSCOPE('Table'[Group1])&&NOT(ISINSCOPE('Table'[Group2]))&&NOT(ISINSCOPE('Table'[Group3])),1,
0)))

2. Result:

vyangliumsft_1-1671780620221.png

 

Best Regards,

Liu Yang

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

5 REPLIES 5
avatar user
Anonymous
Not applicable

Syndicated - Outbound

Hi  @konradjonsson ,

I created some data:

vyangliumsft_0-1671780620218.png

You can use the composition IF + ISINSCOPE() to implement the calculation of the different levels of the matrix.

IF function (DAX) - DAX | Microsoft Learn

ISINSCOPE function (DAX) - DAX | Microsoft Learn

Here are the steps you can follow:

1. Create measure.

Here we have [Group2] and [Group3] to calculate, the remaining two levels can be written directly into the formula to calculate the corresponding level, here Group1 = 1, Total = 0

Flag =
IF(
ISINSCOPE('Table'[Group3]),[Workdays V2],
IF(     ISINSCOPE('Table'[Group2])&&NOT(ISINSCOPE('Table'[Group3])),AVERAGEX(FILTER(ALL('Table'),'Table'[Group2]=MAX('Table'[Group2])),[Workdays V2]),
     IF(   ISINSCOPE('Table'[Group1])&&NOT(ISINSCOPE('Table'[Group2]))&&NOT(ISINSCOPE('Table'[Group3])),1,
0)))

2. Result:

vyangliumsft_1-1671780620221.png

 

Best Regards,

Liu Yang

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

Syndicated - Outbound

Thank you Liu Yang!

Your suggestion solved my problem.

(another suggestion, from an another user, was to include "averagex(values(..." around the networkdays-function, but that did not help in my dataset)

konradjonsson
Helper II
Helper II

Syndicated - Outbound

Thanks. Will try suggestion later.

amitchandak
Super User
Super User

Syndicated - Outbound

@konradjonsson , You need to create a measure like

 

AvergaeX(Values(Table[Region]), calculate(networkdays(Startofmonth('Date-Main'[WkDate]), Endofmonth('Date-Main'[WkDate]), 1,Holidays) ))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Syndicated - Outbound

Hi Amit.

Thank you for your input! It did however not solve the problem in my dataset. I used the suggestion, from Liu Yang, that worked.

avatar user

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)