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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
cristianml
Post Prodigy
Post Prodigy

Dax measure between 2 tables (New, Removed, Promoted)

Hi,

 

I have 2 tables and 2 columns and with this I need to create a formula based on 4 different scenarios:

Logic (scenarios):
IF Forecast[Name] IS NOT IN Actual[Name] THEN "Removed"
IF Actual[Name] IS NOT IN Forecast[Name] THEN "New"
IF Actual[Name] IS EQUAL TO Forecast[Name] THEN IF Actual[Level] IS EQUAL TO Forecast[Level] THEN BLANK
IF Actual[Name] IS EQUAL TO Forecast[Name] THEN IF Actual[Level] IS NOT EQUAL TO Forecast[Level] THEN "Promoted"

 

Actual
LevelName
Senior Managerhenry
Senior Analystantonio
Analysttom
Analystanna

 

Forecast
LevelName
Senior Managerhenry
Analystantonio
Analysttom
Senior Analyststuart

 

So in my visual I should see the measure with sometinhg like this:

 

My Visual
LevelNameMeasure
Senior Managerhenry 
Senior AnalyststuartRemoved
Analysttom 
Senior AnalystantonioPromoted
AnalystantonioPromoted
AnalystannaNew

 

Thanks,

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @cristianml ,

 

New a calculated table.

Table_1 = UNION(Actual,Forecast)

1.PNG

 

Add fields from above table into visual, and create below measure.

Measure =
VAR _isinActual =
    IF ( SELECTEDVALUE ( Table_1[Name] ) IN VALUES ( Actual[Name] ), 1, 0 )
VAR _isinForecast =
    IF ( SELECTEDVALUE ( Table_1[Name] ) IN VALUES ( Forecast[Name] ), 1, 0 )
VAR _LevelinActual =
    CALCULATE (
        SELECTEDVALUE ( Actual[Level] ),
        FILTER ( Actual, Actual[Name] = SELECTEDVALUE ( Table_1[Name] ) )
    )
VAR _LevelinForecast =
    CALCULATE (
        SELECTEDVALUE ( Forecast[Level] ),
        FILTER ( Forecast, Forecast[Name] = SELECTEDVALUE ( Table_1[Name] ) )
    )
RETURN
    IF (
        _isinActual = 0
            && _isinForecast = 1,
        "Removed",
        IF (
            _isinActual = 1
                && _isinForecast = 0,
            "New",
            IF (
                _isinActual = 1
                    && _isinForecast = 1,
                IF ( _LevelinActual = _LevelinForecast, BLANK (), "Promoted" )
            )
        )
    )

2.PNG

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @cristianml ,

 

New a calculated table.

Table_1 = UNION(Actual,Forecast)

1.PNG

 

Add fields from above table into visual, and create below measure.

Measure =
VAR _isinActual =
    IF ( SELECTEDVALUE ( Table_1[Name] ) IN VALUES ( Actual[Name] ), 1, 0 )
VAR _isinForecast =
    IF ( SELECTEDVALUE ( Table_1[Name] ) IN VALUES ( Forecast[Name] ), 1, 0 )
VAR _LevelinActual =
    CALCULATE (
        SELECTEDVALUE ( Actual[Level] ),
        FILTER ( Actual, Actual[Name] = SELECTEDVALUE ( Table_1[Name] ) )
    )
VAR _LevelinForecast =
    CALCULATE (
        SELECTEDVALUE ( Forecast[Level] ),
        FILTER ( Forecast, Forecast[Name] = SELECTEDVALUE ( Table_1[Name] ) )
    )
RETURN
    IF (
        _isinActual = 0
            && _isinForecast = 1,
        "Removed",
        IF (
            _isinActual = 1
                && _isinForecast = 0,
            "New",
            IF (
                _isinActual = 1
                    && _isinForecast = 1,
                IF ( _LevelinActual = _LevelinForecast, BLANK (), "Promoted" )
            )
        )
    )

2.PNG

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yulgu-msft,

 

Thanks for your measure. I tried to replicate it in my model but i have a problem. My forecast table is based on a selected value cause I have 7 different versions of FORECAST. And to list the Names/and Levels I created an append table with all tables together and I take from there the list for the visual. See the pictures :

NAME MEASURE.jpg

comparison.jpg

 

How can I solve/replicate this part ?:  IN VALUES ( Forecast[Name] ), 1, 0 )

 

Thanks 

 

 

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.