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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
babbles
New Member

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!

Picture1.png

 

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 1
Anonymous
Not applicable

Hi @babbles ,

 

Please try:

VAR networkdays_count = SUMX(VALUES('Table'[company]), NETWORKDAYS(StartValue, EndValue))

Why Power BI totals might seem inaccurate - SQLBI

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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