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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
owallis
Frequent Visitor

SUM Column but retrieve a value from another table if (blank) value

Hi All,

 

I'm trying to SUM a column in table1 but if the value is (blank) then I want to use the value from table1 based on date, prefix (the other columns). There is no direct relationship between the two tables but are proxy linked through prefix and date tables

 

Prefix and Date table are pulled in from an external source and then linked so it is possible to slice/filter mutliple tables. 

 

example power bi.PNG

 

I feel this should be easily do-able but must be missing a trick with relationships. 

 

Any suggestions will be welcomed

 

Many thanks,

Oliver

 

 

 

 

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @owallis ,

 

How about create a "Value 2" column in "Forecast" table?

Value 2 = 
VAR PlanValue =
    LOOKUPVALUE (
        Plan[Value],
        Plan[Date], Forecast[Date],
        Plan[Prefix], Forecast[Prefix]
    )
RETURN
    IF ( ISBLANK ( Forecast[Value] ), PlanValue, Forecast[Value] )

forecast.PNG

 

Or, modified @mahoneypat 's measure like so:

NewMeasure =
VAR __planvalue =
    SUM ( Plan[Value] )
VAR __forecastvalue =
    CALCULATE (
        SUM ( Forecast[Value] ),
        TREATAS ( VALUES ( Plan[Date] ), Forecast[Date] ),
        TREATAS ( VALUES ( Plan[Prefix] ), Forecast[Prefix] )
    )
RETURN
    IF ( ISBLANK ( __forecastvalue ), __planvalue, __forecastvalue )
Measure 2 =
IF (
    HASONEVALUE ( 'Date'[Date] ),
    [NewMeasure],
    SUMX ( 'Forecast', [NewMeasure] )
)

measure2.PNG

 

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

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
Icey
Community Support
Community Support

Hi @owallis ,

 

How about create a "Value 2" column in "Forecast" table?

Value 2 = 
VAR PlanValue =
    LOOKUPVALUE (
        Plan[Value],
        Plan[Date], Forecast[Date],
        Plan[Prefix], Forecast[Prefix]
    )
RETURN
    IF ( ISBLANK ( Forecast[Value] ), PlanValue, Forecast[Value] )

forecast.PNG

 

Or, modified @mahoneypat 's measure like so:

NewMeasure =
VAR __planvalue =
    SUM ( Plan[Value] )
VAR __forecastvalue =
    CALCULATE (
        SUM ( Forecast[Value] ),
        TREATAS ( VALUES ( Plan[Date] ), Forecast[Date] ),
        TREATAS ( VALUES ( Plan[Prefix] ), Forecast[Prefix] )
    )
RETURN
    IF ( ISBLANK ( __forecastvalue ), __planvalue, __forecastvalue )
Measure 2 =
IF (
    HASONEVALUE ( 'Date'[Date] ),
    [NewMeasure],
    SUMX ( 'Forecast', [NewMeasure] )
)

measure2.PNG

 

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

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

mahoneypat
Microsoft Employee
Microsoft Employee

Not exactly sure what you are trying to accomplish but suspect you can get there with an approach like this.

 

NewMeasure =
VAR __planvalue =
SUM ( Plan[Value] )
VAR __forecastvalue =
CALCULATE (
SUM ( Forecast[Value] ),
TREATAS ( VALUES ( Plan[Date] ), Forecast[Date] ),
TREATAS ( VALUES ( Plan[Prefix] ), Forecast[Prefix] )
)
RETURN
IF ( ISBLANK ( __planvalue ), __forecastvalue, __planvalue )

 

I would also suggest you simplify your model if possible.  You can likely combine your Forecast and Actuals tables.  Simple model, simple DAX.

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





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

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors