Forum Discussion

owallis's avatar
owallis
Frequent Visitor
6 years ago
Solved

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 betwee...
  • Icey's avatar
    6 years ago

    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] )
    

     

    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] )
    )
    

     

    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.