Create a Calculated Column on more than 2 arguments

Could somebody help me in writing the correct DAX code so that the Calculated Colum “Status” is populated with the values that come from the 2 columns AlliedForces and Germans in MilitaryGroups which serves as a LookUpTable. See also enclosed snap shot with all the details!

  • The end result shoud be 1 Calculated Column called status in the FactTable: BattleGroundActivity.
  • The lookup values have to come from 2 columns in the Table MilitaryGroups into 1 columns named Status in the FactTable: BattleGroundActivity

I made a start with the following DAX code. This is only a small part of the total DAX code, but already in this stadium it returns a False:
Status = AND(BattleGroundActivity[BattleKey]=SELECTEDVALUE(MilitaryGroups[BattleKey]); BattleGroundActivity[MililtaryGroup]=“AlliedForces”:wink:

Arguments I have to use are:

  1. BattleKey
  2. AlliedForces and Germans

Hi @Mischa,

Welcome to the forum.

I think you could sort this in Power Query but you can also do it in DAX
If you have a 1:M relationship between these tables, you can use RELATED
image

for example:

Status = 
 VAR myGroup = BattleGroudActivity[MilitaryGroup]
 RETURN

IF( myGroup = "Germans",
    RELATED( MilitaryGroup[Germans]),
    RELATED(MilitaryGroup[AlliedForces])
)

image

1 Like

@Mischa,

Welcome to the forum! Great to have you here.

Rather than via DAX/calculated columns, I think this task is handled far more easily via Power Query. Just start with your Lookup table, and reference that in Power Query to make a copy.

Now select the Allied Forces and Germans column, right click, and select Unpivot Columns:

Here’s the resulting table which you can then merge with your fact table:

I hope this is helpful.

  • Brian

@Melissa,

Wait - what just happened here? :grinning:

  • Brian

I know, right :thinking:. Still advocating Power Query but also listening to user demand LOL.

Both solutions work and all within a blink of an eye!
Thanks Melissa and Brian :pray: