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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hemanthk
New Member

How to get Sum on Total Row for a measure in DirectQuery?

Hi,

I have a measure to get the days between two dates and I want the total of this measure to be Sum, but it is giving me a MIN value on the total row of the Table Visual.

I am using DirectQuery.

My measure is like below:

1_WDays =
VAR BEGDATE = MIN('ZTAQ_CP03_V01'[Position Open (Posted) Date])
VAR ENDDATE = MIN('ZTAQ_CP03_V01'[Position Hired Date])
VAR HOLIDAYS = CALCULATE(DISTINCTCOUNT('BU Holidays'[Date]),FILTER('BU Holidays', 'BU Holidays'[Date] >= BEGDATE && 'BU Holidays'[Date] <= ENDDATE))
VAR WEEKENDS = CALCULATE(DISTINCTCOUNT(CAL[Date]),FILTER(CAL, CAL[Date] >= BEGDATE && CAL[Date] <= ENDDATE && WEEKDAY(CAL[Date], 2) > 5))
RETURN (DATEDIFF(BEGDATE, ENDDATE, DAY) - HOLIDAYS - WEEKENDS)
 
Can you please suggest how to get the Sum for this measure in DirectQuery.
 
Sum_Measure.png
2 ACCEPTED SOLUTIONS
johnt75
Super User
Super User

Rename your current measure to be "1_Wdays individual" then create a new measure

1_Wdays = IF( ISINSCOPE('Table'[Position number]), [1_Wdays individual],
var summaryTable = ADDCOLUMNS( SUMMARIZE( 'Table', 'Table'[Position number]), 
"@value", [1_Wdays individual])
return SUM( summaryTable, [@value])
)

View solution in original post

Hi,

I fixed it by creating a New Table instead of another measure and adding DAX: ADDCOLUMNS and SUMMARIZE functions to it.

Thanks, John for your input.

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

Rename your current measure to be "1_Wdays individual" then create a new measure

1_Wdays = IF( ISINSCOPE('Table'[Position number]), [1_Wdays individual],
var summaryTable = ADDCOLUMNS( SUMMARIZE( 'Table', 'Table'[Position number]), 
"@value", [1_Wdays individual])
return SUM( summaryTable, [@value])
)

Hi @johnt75 ,

Thank you for your response.

I tried the code as below:

Sum_Measure.png
 
I am getting error: Too many arguments passed to SUM Function.
Can you please let me know what should be corrected?

Hi,

I fixed it by creating a New Table instead of another measure and adding DAX: ADDCOLUMNS and SUMMARIZE functions to it.

Thanks, John for your input.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors