Forum Discussion

babbles's avatar
babbles
New Member
3 years ago

DAX help

Hi Everyone,

 

I'm having some issues with the dax i've used. It is yielding the correct result for the row but the grand total is zero, instead of the sum of the rows. I'm still learning dax and power bi so i may not have used some of the dax functions correctly. I shared an example as an excel just protect some sensitive info and the dax used. 

 

Any help would be great!

 

test _ =
VAR selecteddate = MAX(d_calendar[Date])
VAR empstart_ = SUMX(d_resource_main, SELECTEDVALUE(d_resource_main[datefrom2]))
VAR startyear_ = CALCULATE(STARTOFYEAR(d_calendar[Date]))

VAR StartValue =
    IF(
        HASONEVALUE(d_resource_main[clientResourceid2]),
        IF(
            empstart_ > startyear_,
            empstart_,
            startyear_
        )
    )

VAR empend_ = SUMX(d_resource_main, SELECTEDVALUE(d_resource_main[dateto2]))
VAR endofmonth_ = EOMONTH(selecteddate, 0)
VAR endyear_ = IF(endofmonth_ > TODAY(), TODAY(), endofmonth_)

VAR EndValue =
    IF(
        HASONEVALUE(d_resource_main[clientResourceid2]),
        IF(
            empend_ < endyear_,
            empend_,
            endyear_
        )
    )

VAR networkdays_count = NETWORKDAYS(StartValue, EndValue)

RETURN
networkdays_count

1 Reply