Forum

Active / Inactive r...
 
Notifications
Clear all

Active / Inactive relationship

5 Posts
2 Users
0 Reactions
56 Views
(@alib40)
Posts: 113
Estimable Member
Topic starter
 

Hi

I'm using POWER BI

I have a Calendar table, Contract table, and 1 measure Tot.Contract £

The contract table has 3 dates that I wish to report on - they are all in a relationship with the Date column of the Calendar table

StartDate - Inactive relationship

OrigStartDate - Inactive relationship

ExpiryDate - Active relationship

 

I want to chart by Year/Mth the Tot.Contract £.

How can I tell it which relationship is active for the given charts?

 
Posted : 04/12/2018 6:21 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Alison,

If you don't need to use any of the Time Intelligence functions and your reporting period is in line with the calendar year, i.e. not a fiscal period, then you can simply use the in built date hierarchy, which means you don't need the Calendar table at all.

To do this, add the date you want to see in your chart to the X axis. It will automatically have a hierarchy applied for Month, Quarter and Year. Remove 'Quarter' if you don't need it.

Alternatively, if you need the calendar table then you can write your measure like so to force it to use a specific relationship (note: I've guessed the column names in the formula below):

Tot.Contract := 

CALCULATE( 

   SUM(ContractTable[ContractAmount] ), 

   USERELATIONSHIP(

          ContractTable[StartDate], 

          Calendar[DateKey] 

      ) 

)
Mynda
 
Posted : 04/12/2018 9:15 pm
(@alib40)
Posts: 113
Estimable Member
Topic starter
 

Thank you

 
Posted : 06/12/2018 10:22 am
(@alib40)
Posts: 113
Estimable Member
Topic starter
 

Using the syntax with userelationship

CALCULATE(

   SUM(ContractTable[ContractAmount] ),

   USERELATIONSHIP(

          ContractTable[StartDate],

          Calendar[DateKey]

      )

)

 

How would I filter the result to a given year in the date table?

I'm trying to calculate the sum of contractamount for a given fiscalyear based on the relationship ContractTable[StartDate] --> Calendar[DateKey]

I've tried including FILTER(ContractTable,RELATED(Calendar[FiscalYear])=2017 but that doesn't seem to work

 
Posted : 08/12/2018 1:29 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Alison,

You don't need to use FILTER because CALCULATE's arguments are filters. You should be able to write your measure like this:

Tot.Contract2017: 

=CALCULATE(

  SUM(ContractTable[ContractAmount]), 

  USERELATIONSHIP(

   ContractTable[Start Date], 

   'Calendar'[DateKey]),

   'Calendar'[FiscalYear],'Calendar'[FiscalYear]=2017
)

 

See file attached.

Note: in future please provide more detail surrounding your question and or a sample file so I can answer your question more quickly. Details that weren't clear were whether you wanted to filter in context or explicitly filter in the measure. In the file I've attached you'll see both results are returned.

Thanks,

Mynda

 
Posted : 08/12/2018 7:58 pm
Share: