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
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
Super User
Super User

@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
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