Forum Discussion

Leh's avatar
Leh
New Member
3 years ago
Solved

Subtotal includes blank values

Hello,

 

I need some help getting the subtotal to show the correct value in a Table Matrix by using DAX if possible, rather than using the filter on the page.

 

Below is a screenshot of my expected result and my current "workaround".  My concern with the current workaround is that placing a filter on the page may cause issues with other measures that I will add to the report.

 

Expected Results (even without page filter)

 

The first column calculates all the time entered by a technician for a particular job.  The second and third columns calculate the total hours entered by all technicians for a particular job.  The difference between the second and third columns is that the former excludes the blank lines if the first column is blank.

 

Below is the result if I remove the page filter, notice that the Hours Blank measure calculates each line correctly, but the subtotal is off.

 

Wrong subtotal calculation

 

I wanted the report to show the Subtotal for Hours Blank measure excludes the values of the Labor Hours that the technician has not entered time against.  This is just the tip of the iceberg because later on, I will add another measure for Cost and Billing (this measure has no tie to the Technician but to the Job Number); that is why I wanted to write a measure that is not dependent to the Page Filters.

 

Here is the link to the sample data in the Excel file.   Sample Data Excel 

Here is the link to the PBIX. Subtotal and Grand Total for Job and Technician.pbix 

 

I would greatly appreciate any help.

  • Ashish_Mathur's avatar
    Ashish_Mathur
    3 years ago

    Hi,

    Write this measure

    Hours Blank = SUMX(FILTER(VALUES(Jobs[Job  Number]),[Technician Labor Hours]<>BLANK()),[All Labor Hours])

    Hope this helps.

8 Replies