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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
aj1107
Advocate I
Advocate I

DAX calculation max date and exclude data set

Im trying to create a line chart using below scenario.

 

Table

issueid ,status ,substatus ,cdate

1 ,closed ,mpv ,01/15/2017

1 ,closed ,xyz ,02/19/2017

1 ,open ,xyz ,04/12/2017

2 ,closed ,xyz , 03/12/2017

2 ,closed ,xyz , 05/12/2017

3 ,closed ,xyz ,01/28/2017

 

Scenario :

condition1 Exlude the entire issue id group <if status="open" or status="mpv"> and Condition2 distinctcount(issueid) based on max(cdate) for the issue id. Highlighted green is eligible count when aggregated at month level.

 

Result : 

Month, Issue

Jan17, 1

May17, 1

 

Solution : I was able to get the result by implementing the sceanrio at database level  or through DAX query by creating calculated table (condition1) and calculated column rankx function to identify the max date for each issueid(condition2) and finally claculated measure to include condition1 and codition2 :

calculate(distinctcount(issueid),filter(table,issueid<>related(calculatedtable) && maxdate=1)) 

 

Just want to check is there any scope to finetune the dax calculation. Any other alternate way to get the same result.

 

Thank you,

1 ACCEPTED SOLUTION
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @aj1107

 

I had some success with this approach.  I created a new calcualted table using the following code

 

Table = 
VAR ExcludeThese = SUMMARIZE(FILTER('Table1','Table1'[status] ="Open" || Table1[substatus] = "mpv"),Table1[Issueid],"Blank",1)
VAR ReturnTable =SUMMARIZE(
            SUMMARIZE(
                FILTER(
                    NATURALLEFTOUTERJOIN(Table1,ExcludeThese),
                    [Blank] = blank()
                    ),
                    'Table1'[Issueid],"Max Date" ,
                    MAX('Table1'[cdate])
                    ),
                    [Max Date],
                    "Issue",
                    DISTINCTCOUNT(Table1[Issueid])
                    )
RETURN SELECTCOLUMNS(ReturnTable,"Month",FORMAT([Max Date],"MMMYY"),"Issue",[Issue])

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

1 REPLY 1
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @aj1107

 

I had some success with this approach.  I created a new calcualted table using the following code

 

Table = 
VAR ExcludeThese = SUMMARIZE(FILTER('Table1','Table1'[status] ="Open" || Table1[substatus] = "mpv"),Table1[Issueid],"Blank",1)
VAR ReturnTable =SUMMARIZE(
            SUMMARIZE(
                FILTER(
                    NATURALLEFTOUTERJOIN(Table1,ExcludeThese),
                    [Blank] = blank()
                    ),
                    'Table1'[Issueid],"Max Date" ,
                    MAX('Table1'[cdate])
                    ),
                    [Max Date],
                    "Issue",
                    DISTINCTCOUNT(Table1[Issueid])
                    )
RETURN SELECTCOLUMNS(ReturnTable,"Month",FORMAT([Max Date],"MMMYY"),"Issue",[Issue])

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors