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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
PawelTr
Regular Visitor

Group by several criteria and take oldest available value

Hello!

I'm struggling with DAX code.

To describe the problem, look at the picture below. I have many rows with the data, separated by invoice month, country, section, supplier type. In next four rows are some values, let's focus as example on Sum_selling_price

PawelTr_0-1683728624510.png


I want to create calculated column, which always take value for first available month(here it will be April) and assign in all 12 rows. 

My current code, where I failed looks as provided

PawelTr_1-1683728834777.png


I faced "circular dependency".

I would be really grateful for any help.



1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @PawelTr 

 

You can try the following methods.

Selling price = 
Var _firstdate=CALCULATE(MIN('Table'[INVOICE_MONTH_END]),ALL('Table'))
Return
CALCULATE(SUM('Table'[Sum_selling_price]),FILTER('Table',[INVOICE_MONTH_END]=_firstdate))

vzhangti_0-1683874382994.png

Is this the result you expect? If not, please provide more information.

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
PawelTr
Regular Visitor

Hello v-zhangti,

Sorry for beeing silent for a long time. I wasn't able to log in recently.
Your advice helped me solved this problem. 

A veeery big thank you for this support! 😊

v-zhangti
Community Support
Community Support

Hi, @PawelTr 

 

You can try the following methods.

Selling price = 
Var _firstdate=CALCULATE(MIN('Table'[INVOICE_MONTH_END]),ALL('Table'))
Return
CALCULATE(SUM('Table'[Sum_selling_price]),FILTER('Table',[INVOICE_MONTH_END]=_firstdate))

vzhangti_0-1683874382994.png

Is this the result you expect? If not, please provide more information.

 

Best Regards,

Community Support Team _Charlotte

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.