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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Mayank_Yavda
Resolver II
Resolver II

need help with calculated column

I have a table named A in which i have two column - date and sales - and i have another table B with three columns - start date , end date and category - where in table B I only have 4 rows for 4 categories.

So i want to add a column in table A such that if date in table A lies between Start date and end date of Table B then it returns category based on date range it lies in.

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Mayank_Yavda 

Pls try to create a column

Column = MAXX(FILTER(TableB,TableB[Startdate]<='TableA'[date]&&TableB[Enddate]>='TableA'[date]),TableB[Category])

pls see the attachment below.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Enter this calculated column formula in TableA

Category = calculate(max(TableB[category]),filter(TableB,TableB[Start Date]<=earlier(TableA[Date])&&TableB[End Date]>=earlier(TableA[Date])))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ryan_mayu
Super User
Super User

@Mayank_Yavda 

Pls try to create a column

Column = MAXX(FILTER(TableB,TableB[Startdate]<='TableA'[date]&&TableB[Enddate]>='TableA'[date]),TableB[Category])

pls see the attachment below.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks @ryan_mayu, with some changes according to my requirement your solution is working fine for me.

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




mh2587
Super User
Super User

Would you provide data and expected output


✔ Answered? Mark as solution

Muhammad Hasnain | Super User • Fabric • Power BI • Data Engineering

Let's connect on LinkedIn

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.