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
Kebas_Leech
Helper I
Helper I

Row context problem

Hello everyone,

 

I have a daily target measure that calculates the targets for each day of the month based on a fixed monthly target: (the daily target is always the same each day of that specific month).

So i had to calculate the [NumberDaysMonth] and filter it according to the respective holidays of that month.

Total NumberDaysMonth = 
Var TotalDays =
SUMX (
    SUMMARIZE (
        ADDCOLUMNS (
            VALUES ( Tab_Origem[Data] ),
            "EOMonth", EOMONTH ( Tab_Origem[Data], 0 )
        ),
        [EOMonth]
    ),
    DAY ( [EOMonth] )
)
Var NrHolidays = 
   SUMX(
    SUMMARIZE(
        Tab_Origem,
        Tab_Origem[Data],
        Tab_Origem[Holidays],
        "Count", COUNTROWS(Tab_Origem)
    ),
    IF( Tab_Origem[Holidays] = "Yes", [Count], 0)
)

RETURN TotalDays-NrHolidays

Kebas_Leech_0-1687344736213.png  

My problem is that it calculates on a row filter context based on the holiday day (1st of May). I need all remaining May days to have the same number as the respective lowest value calculated. In my example its 30 so I need all May days  to be 30. If it had two holidays it needed to be 29, and so on.

 

How can I manage that? 

Thank you.

5 REPLIES 5
devanshi
Helper V
Helper V

CountHolidays = 
VAR holidays = MINX(FILTER('TableName', [Holiday] = True), COUNT('TableName'))
VAR selectedmonth = CALCULATE(COUNTROWS('TableName'), [Month] = SELECTEDVALUE[Month] &&  [Hloday] <> True)
RETURN
 IF([Holiday] = True, holidays, selectedmonth)

Couldnt make that measure to work.

[Holidays] is not a measure but a columm -> Tab_Origem[Holidays].
I dont have any measure named [Month] only a data column named Tab_Origem[Data]

some_bih
Super User
Super User

Hi @Kebas_Leech it seems you need to calculate NETWORKDAYS. Check links with examples. Hope this help

https://learn.microsoft.com/en-us/dax/networkdays-dax 

https://dax.guide/networkdays/ 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Doesnt work. At least for two reasons:

1) I only have listed working days in my database
2) and even if a consider the following code:

 

Var Firstday = STARTOFMONTH(Tab_Origem[Data])
Var EndDay = ENDOFMONTH(Tab_Origem[Data])
Var HolidayDate = CALCULATETABLE(VALUES(Tab_Origem[Data]), 'Tab_Origem'[Holidays] = "Yes")

Var Net =
    NETWORKDAYS(Firstday, EndDay, 1, HolidayDate)

 

 It does the same mistake/problem that I had in the first post, and that is : Whenever the Tab_Origem[ Holidays] is "Yes" the corresponding date always has one less total day. Using the code i wrote here , the result is:

Kebas_Leech_0-1687369230887.png

As you see the May 1st as one less day.

I want, in May , all days to be 30 because i only have 1 holiday in this month and all the other are workingdays.

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.