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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
ramiro_gonzalez
Frequent Visitor

Use Realated with calculate

Hi everyone, I’d appreciate your help. I’m trying to use a filter with the RELATED function inside CALCULATE, something like:
CALCULATE(COUNTDISTINCT(Id), Sales[Date] < RELATED(Orders[ExpirationDate])).
I get an error saying that the column used in RELATED doesn’t exist. I know a row context is needed, but in this case I want to avoid using FILTER to filter a whole table.

1 ACCEPTED SOLUTION
Deku
Super User
Super User

CALCULATE(

COUNTDISTINCT(Id),

Filter(

Summarize(

Orders,

Sales[Date],

Orders[ExpirationDate]

),

Sales[Date] < Orders[ExpirationDate]

)

)


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

3 REPLIES 3
v-mdharahman
Community Support
Community Support

Hi @ramiro_gonzalez,

Thanks for reaching out to the Microsoft fabric community forum.

 

It looks like you are facing issue in your DAX. As @Deku and @bhanu_gautam both responded to query, please go through the responses and mark the helpful reply as solution.

 

I would also take a moment to thank @Deku and @bhanu_gautam, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

 

If I misunderstand your needs or you still have problems on it, please feel free to let us know.  

Best Regards,
Hammad.
Community Support Team

 

If this post helps then please mark it as a solution, so that other members find it more quickly.

Thank you.

Deku
Super User
Super User

CALCULATE(

COUNTDISTINCT(Id),

Filter(

Summarize(

Orders,

Sales[Date],

Orders[ExpirationDate]

),

Sales[Date] < Orders[ExpirationDate]

)

)


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
bhanu_gautam
Super User
Super User

@ramiro_gonzalez , Use 

DAX
CALCULATE(
COUNTDISTINCT(Sales[Id]),
TREATAS(
VALUES(Sales[Date]),
Orders[ExpirationDate]
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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