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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Brookied1974
Frequent Visitor

Help request to define Subtotal in Column

Hi All, 

Hope you are all well,  My Friday brain has kicked in and cannot figure this one out.  So i am building a office occupancy report and was asked if i could add a staff frequency visual.  i have the below which when i use dept filters and weekly filters will show how many times that person was in this week.  I have a data set where i count if a user had a flag activiated on a keypass panel for exit of said building, if so then they were in that day.  I am using distinctcount to show 1 entry per day recorded per person as one person could exit 27 times but i just need one instance.  I can get a total count (how many per day) as per below but i want a count per column on the right and if the count is 0 or 1 in any given week i can highlight and ask the "why" .  i want the count to reflect for example from below

Row 1 = 2

Row 2 = 4

Row 3 = 1

 

 

When i turn on column subtotals and row subtotals I get a value of 1 on everything so i used the below dax but this gave me the total for rows not columns 

Event Count =
SUMX(DISTINCT('Attendance MD'[Event]),
CALCULATE(DISTINCTCOUNT('Attendance MD'[Full Name])))

 

 

I have a table called "Attendance MD" 

fields i am using are:- Full name, Event (distinct Count)

 

Capture.JPG

 Thanks in advance and Happy new year 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Brookied1974 ,

 

 

Here are the steps you can follow:

1. Create measure.

Measure =
var _table1=
SUMMARIZE('Attendance MD','Attendance MD'[Event],"Value",[Event Count])
var _if=
IF(
    ISINSCOPE('Attendance MD'[Event]),[Event Count],SUMX(_table1,[Value]))
var _table2=
SUMMARIZE('Attendance MD','Attendance MD'[Full name],"Value",[Event Count])
return
IF(
   ISINSCOPE('Attendance MD'[Full name]),_if,SUMX(_table2,[Value]))

2. Result:

vyangliumsft_0-1673233805804.png

 

Best Regards,

Liu Yang

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

2 REPLIES 2
Brookied1974
Frequent Visitor

HI, thanks a million, that worked although i did make a slight change to my dataset as i had multiple events on the same day so i did some clean up to help the measure.   Thanks though. 

Anonymous
Not applicable

Hi  @Brookied1974 ,

 

 

Here are the steps you can follow:

1. Create measure.

Measure =
var _table1=
SUMMARIZE('Attendance MD','Attendance MD'[Event],"Value",[Event Count])
var _if=
IF(
    ISINSCOPE('Attendance MD'[Event]),[Event Count],SUMX(_table1,[Value]))
var _table2=
SUMMARIZE('Attendance MD','Attendance MD'[Full name],"Value",[Event Count])
return
IF(
   ISINSCOPE('Attendance MD'[Full name]),_if,SUMX(_table2,[Value]))

2. Result:

vyangliumsft_0-1673233805804.png

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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