Forum Discussion

asjones's avatar
asjones
Helper V
8 years ago

Calculated Column / Measure With filter Criteria From Secondary Table with single Row

 

 

I have a large table with many columns including  various amounts and period (year/month). I have a secondary table with a single row of various parameters about the data pull.

 

If I try and reference the period column in the secondary table in DAX then I get an error. However if I hard code the period  from the secondary table then the new column is created correctly.

 

I am not sure I am doing the DAX the best way however this seemed to work

 

This seems to work:

Amount4_YTD = CALCULATE( sum(Project_Data[plA_Amount4_Year]) , Project_Data[Award] = "AWARD1" , FILTER( Project_Data, Project_Data[period] <= 201801 ))

 

This does not work:

pla_Amount4_YTD_HFR1 = CALCULATE( sum(Project_Data[plA_Amount4_Year]) , Project_Data[Award] = "HPIAA*" , FILTER( Project_Data, Project_Data[period] <= General_Environment[cperiod] ))

 

what am I missing?

 

Thanks

 

Alan

 

 

 

 

2 Replies

  • Insecond measure, General_Environment[cperiod] doesn't have a row context so i would expect the calculated column to fail.  You need to wrap column in MAX, MIN, or some other scalar function.

     

    Is there a relationship between the two tables? 

    • asjones's avatar
      asjones
      Helper V

      I don't have a relation between the two tables. The General_Environment table has 1 row and a 2nd row with nulls that is preventing PowreBI from allwoing a relation. I am having trouble keepting the nulls out everytime out of my data.

       

       

      I really liked your idea of wrapping the column in max(). That did not give an error, but seemed to give no results.

      Amount4_YTD_HFR2 = CALCULATE( sum(Project_Data[plA_Amount4_Year]) , Project_Data[Award] = "HPIAA*" , FILTER( Project_Data, Project_Data[period] <= max(General_Environment[cPeroid] )))

       

      thanks for the response and ideas

       

      Alan