Reply
admin_xlsior
Post Prodigy
Post Prodigy
Partially syndicated - Outbound

DAX : How to SummarizeColumn with certain condition

Dear friends,

 

I have data that need to summarize, but at one of its column, I needed to show the last date (maximum date) on the related key row.

The data is something like this :

admin_xlsior_0-1636095065607.png 

and the expection is to summarize this ItemId, Quantity, CostAmount, which is the 2 last column is easy (just use SUM), but the TransDate I want to retrieve only the last date when quantity is positive, like this :

admin_xlsior_1-1636095188704.png

I tried like this ->

Invetory = ADDCOLUMNS(
                        SUMMARIZECOLUMNS('inventory data'[ItemId], "Qty", SUM('inventory data'[Quantity]), "Amount", SUM('inventory data'[Cost amount]) ),
                        "InflowDate", MAX('inventory data'[TramsDate])
                        )

But the date is not the date of related ItemId, but the Max date overall, not to mentioned I don't know where to put the condition of the Quantity should be > 0.

 

Thanks

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Syndicated - Outbound

@admin_xlsior , Try like

 

Invetory = ADDCOLUMNS(
SUMMARIZECOLUMNS('inventory data'[ItemId], "Qty", SUM('inventory data'[Quantity]), "Amount", SUM('inventory data'[Cost amount]) ),
"InflowDate", MAXX(filter('inventory data', [ItemId] = earlier([ItemId])),[TramsDate])
)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

Syndicated - Outbound

@admin_xlsior , Try like

 

Invetory = ADDCOLUMNS(
SUMMARIZECOLUMNS('inventory data'[ItemId], "Qty", SUM('inventory data'[Quantity]), "Amount", SUM('inventory data'[Cost amount]) ),
"InflowDate", MAXX(filter('inventory data', [ItemId] = earlier([ItemId])),[TramsDate])
)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)