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
VTSDEV
Regular Visitor

DAX Selectvalue measure Totals not showing in a table

Hi All,

 

I have recently developed a measure which calculates a cummulative average (GP Final) of a particular week day during a set period of time (last one year) and averages of a public holiday if the day is a public holiday. The measure works perfectly but i was unable to obtain the totals in the totals row of the table.

 

 

DAX formulea - 


Disp Daily Average =
VAR MaxDate = MAX( 'Date'[Date] ) -- retrieve latest date
VAR MinDate = EDATE( MaxDate, -12 ) -- move it back 12 months
VAR Result =
if(CONTAINSSTRING(SELECTEDVALUE('Date'[State for Public Holiday]),SELECTEDVALUE('Main Table'[SSTATE])),CALCULATE(
SUM('Main Table'[GP Final])/COUNT('Date'[Date]),'Main Table'[SCODELEVEL1] = "DISPENSARY",
FILTER( ALL( 'Date' ), -- return period between
CONTAINSSTRING('Date'[State for Public Holiday],SELECTEDVALUE('Main Table'[SSTATE]))-- bigger than year before
)),CALCULATE(
SUM('Main Table'[GP Final])/COUNT('Date'[Date]),'Main Table'[SCODELEVEL1] = "DISPENSARY",
FILTER( ALL( 'Date' ), -- return period between
'Date'[Date] <= MaxDate && -- latest date
'Date'[Date] > MinDate && 'Date'[Weekday] = SELECTEDVALUE('Date'[Weekday]) -- bigger than year before
)))
RETURN
Result

VTSDEV_1-1637291095866.png

 

 

Table - 

VTSDEV_0-1637291085836.png

 

 

Any help will be greatly appreciated

1 ACCEPTED SOLUTION

Hi @VTSDEV ,

 

You want to calculate total in total rows please to hasonevalue(). This function is often used to control if the content is the total rows. If TRUE, return the calculation for total, FALSE, return calculation for items.

HASONEVALUE function (DAX) - DAX | Microsoft Docs

 

If I misunderstood you please let me know.

 

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@VTSDEV , In such case you have to change your return using summarize or values

 

Example

return

 

refer

https://www.youtube.com/watch?v=ufHOOLdi_jk

Sumx(addcolumns(summarize(Date, Date[Date]), "_1", result ), [_1]_

Unfortunately, I think it didnt work. Or maybe i am missing something?

VTSDEV_0-1637293924702.png

 

Hi @VTSDEV ,

 

You want to calculate total in total rows please to hasonevalue(). This function is often used to control if the content is the total rows. If TRUE, return the calculation for total, FALSE, return calculation for items.

HASONEVALUE function (DAX) - DAX | Microsoft Docs

 

If I misunderstood you please let me know.

 

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.