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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
kilala
Resolver I
Resolver I

Add Condition in Calculated Column

Hi all,

 

I have 2 Fact Tables, FactA and FactB. FactB needs to get info from FactA. Both FactA and FactB can connect via PayerKey. In FactA, there is DateKey, referring to reportingdate. In FactB, the Datekey is referring to OrderDate. 

 

I want to create a calculated column in FactB, that gets the [Measure] which logic is from FactA, where datekey in FactA is the latest date in FcatA.

 

Current formula I used is as below, but it is wrong:
var latestdate = MAX(FactB[DateKey])

 

return

IF(

CALCULATE([Measure], USERELATIONSHIP(vw_FactB[PayerKey], vw_DimPayer[PayerKey]),vw_FactA[DateKey]=latestdate) = BLANK(), 0,

CALCULATE([Measure], USERELATIONSHIP(vw_FactB[PayerKey], vw_DimPayer[PayerKey]),vw_FactA[DateKey]=latestdate)

)

 

Please help 🙂

 

 

1 ACCEPTED SOLUTION
kilala
Resolver I
Resolver I

Hi everyone, 

I tried to use this formula and apparently it works! 

CALCULATE([Measure],ALLEXCEPT(vw_FactB,VW_DIMPAYER[PayerKey]))
 
I think I dont have connect to FactB since I already have it in my measure.
 
Thanks everyone!

View solution in original post

3 REPLIES 3
kilala
Resolver I
Resolver I

Hi everyone, 

I tried to use this formula and apparently it works! 

CALCULATE([Measure],ALLEXCEPT(vw_FactB,VW_DIMPAYER[PayerKey]))
 
I think I dont have connect to FactB since I already have it in my measure.
 
Thanks everyone!
v-easonf-msft
Community Support
Community Support

Hi, @kilala 

There are no syntax errors from the current formula.

Is there any other specific error message?

Best Regards,
Community Support Team _ Eason

MFelix
Super User
Super User

Hi @kilala ,

 

When you refer to t eh MAX date your context since it's on a table it will pick up the current line context so your line will return the exact value, is that the intedend result?

 

Can you please share a mockup of your data?


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português





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.

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.