cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tony_Tony
Frequent Visitor

Sum most recent value with group conditions

Hi there!
I think I'm close to getting my desired output but somehow I am missing part of the DAX and it doesnt add up in the Total. I have this data and the goal is to identify the most recent one per ticket age, display in the table (that part I was able to get). However, the DAX that I've tried does not add up in the total (kindly see image below) so I can display the how many tickets are open.

ACCOUNT NAMEDATEDAYMONTHTICKET AGETotal Tickets
A2/27/2023MonFeb-23<1 Day0
A2/27/2023MonFeb-231-3 Days15
A2/27/2023MonFeb-234-10 Days86
A2/27/2023MonFeb-2311-20 Days16
A2/27/2023MonFeb-23>20 Days2
B2/27/2023MonFeb-23<1 Day72
B2/27/2023MonFeb-231-3 Days293
B2/27/2023MonFeb-234-10 Days145
B2/27/2023MonFeb-2311-20 Days24
B2/27/2023MonFeb-23>20 Days13
C2/27/2023MonFeb-23<1 Day8
C2/27/2023MonFeb-231-3 Days103
C2/27/2023MonFeb-234-10 Days44
C2/27/2023MonFeb-2311-20 Days3
C2/27/2023MonFeb-23>20 Days0
A2/28/2023TueFeb-23<1 Day0
A2/28/2023TueFeb-231-3 Days15
A2/28/2023TueFeb-234-10 Days86
A2/28/2023TueFeb-2311-20 Days16
A2/28/2023TueFeb-23>20 Days2
C2/28/2023TueFeb-23<1 Day8
C2/28/2023TueFeb-231-3 Days103
C2/28/2023TueFeb-234-10 Days44
C2/28/2023TueFeb-2311-20 Days3
C2/28/2023TueFeb-23>20 Days0
B2/28/2023TueFeb-23<1 Day72
B2/28/2023TueFeb-231-3 Days293
B2/28/2023TueFeb-234-10 Days145
B2/28/2023TueFeb-2311-20 Days24
B2/28/2023TueFeb-23>20 Days13

 

 

Table visual in Power BI

Tony_Tony_0-1686343175868.png

I tried a number of dax measures and the last one shown in the table with the max values is below. Kindly let me know how to proceed. Thank you in advance.

Ticket <1 Day =
VAR MAX_D = MAX(Source[DATE])
VAR OneDay= CALCULATE(
                            SUM(Source[TICKET AGE COUNT]),
                            Source[TICKET AGE]="<1 Day",
                            Source[DATE]=MAX_D
          
                )
RETURN
OneDay
1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Tony_Tony ,

 

Please try:

Measure = 
SUMX(FILTER('Source',[TICKET AGE]="<1 Day"&&[DATE]=CALCULATE(MAX('Source'[DATE]),FILTER('Source',[ACCOUNT NAME]=EARLIER(Source[ACCOUNT NAME])))),[Total Tickets])

Final output:

vjianbolimsft_0-1687834721751.png

Best Regards,

Jianbo Li

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
v-jianboli-msft
Community Support
Community Support

Hi @Tony_Tony ,

 

Please try:

Measure = 
SUMX(FILTER('Source',[TICKET AGE]="<1 Day"&&[DATE]=CALCULATE(MAX('Source'[DATE]),FILTER('Source',[ACCOUNT NAME]=EARLIER(Source[ACCOUNT NAME])))),[Total Tickets])

Final output:

vjianbolimsft_0-1687834721751.png

Best Regards,

Jianbo Li

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

Mahesh0016
Solution Sage
Solution Sage

@Tony_Tony i hope this helps you!THANK YOU!!

Ticket <1 Day =
VAR MAX_D = MAX('Table E'[DATE])
VAR OneDay= CALCULATE(
                            SUM('Table E'[Total Tickets]),
                            FILTER(ALLSELECTED('Table E'[DATE]),'Table E'[DATE] = MAX_D),
                            ALLEXCEPT('Table E','Table E'[TICKET AGE])
         
                )
RETURN
OneDay

Thank you @Mahesh0016 for the reply. However, when I apply the function, I think it's adding up the latest entry of the Accounts column with the same max date. I tried other measure but it doesnt work when I use a month slicer. For June, it shows the max data just right but when I selected May, its blank. This is the output when I utilised the above measure

Tony_Tony_0-1686450376311.png

 



Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Top Solution Authors
Top Kudoed Authors