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

SUMMARIZE functions for new table

Hello,

 

I am trying to create new table from the existing table based on the date selected. but the results are not as expected from the DAX formulas.

 

current table

Instrument        Transaction       Date                   Amount     
ABuy1-Jun-10-25
ABuy5-Jun-10-75
ASell19-Jun-1030
AMonthEnd30-Jun-1060
ABuy1-Jul-10-125
ABuy5-Jul-10-85
ASell19-Jul-10300
AMonthEnd30-Jul-10400
CBuy10-Jun-10-89
CSell20-Jun-1045
CMonthEnd30-Jun-10120
CBuy8-Jul-10-75
CSell22-Jul-1030
CMonthEnd30-Jul-1060

 

if the user selected date is 30-jul-10   only july "month end" data should be considered along with other transaction.

 

Expected table :

Instrument                Transaction              Date                   Amount           
ABuy1-Jun-10-25
ABuy5-Jun-10-75
ASell19-Jun-1030
ABuy1-Jul-10-125
ABuy5-Jul-10-85
ASell19-Jul-10300
AMonthEnd30-Jul-10400
CBuy10-Jun-10-89
CSell20-Jun-1045
CBuy8-Jul-10-75
CSell22-Jul-1030
CMonthEnd30-Jul-1060

tried with SUMMARIZE functions

Can someone help me on this?

 

Thanks

 

2 REPLIES 2
lbendlin
Super User
Super User

Following this example

https://community.powerbi.com/t5/Desktop/How-to-find-latest-date-value-in-a-group/td-p/379104

here's a sample measure that you can add to your table and use for filtering.

 

Include = 
var latest = CALCULATE(max(Table[Date                  ])
    ,Table[ Transaction       ]="MonthEnd"
    ,ALLEXCEPT(Table,Table[Instrument       ]))
return SWITCH(TRUE(),MAX(Table[ Transaction       ])<>"MonthEnd",1
    ,max(Table[Date                  ])=latest,1
    ,0)

 

here's a slightly more robust implementation that handles date filters better (for example if you chose to exclude July 30 for whatever reason)

 

Include = 
var i = max(Table3[Instrument       ])
var a = ALLSELECTED(Table3)
var latest = CALCULATE(max(Table3[Date                  ])
    ,Table3[ Transaction       ]="MonthEnd"
    ,Table3[Instrument       ]=i
    ,a)
var s = SWITCH(TRUE(),MAX(Table3[ Transaction       ])<>"MonthEnd",1
    ,max(Table3[Date                  ])=latest,1
    ,0)
return s

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