Forum Discussion

analystict's avatar
analystict
Icon for Helper I rankHelper I
8 years ago
Solved

Date Hierarchy affects calculated measures

Hey there,

 

Say I have two calculated measures, one measures how many leads were converted, the DAX forumla is:

 

MU_Conversions_Affiliate_ThisYear = 

VAR currentYear = VALUE(FORMAT(TODAY(), "YYYY"))

VAR TotalConversions = 
    CALCULATE(
        COUNTA('Lead'[conversiondate]),
        'Lead'[conversiondate].[Year] IN { currentYear },
        ALL('Lead'[conversiondate].[MonthNo]),
        FILTER('Lead',
             'Lead'[affiliate_ref] <> "" &&
            ISBLANK('Lead'[affiliate_ref]) = FALSE()
        )
    )
    
    RETURN TotalConversions

The other one checks how many leads were created, the DAX formula is:

 

MU_TotalLeads_Affiliate_ThisYear = 
 
VAR currentYear = VALUE(FORMAT(TODAY(), "YYYY"))

VAR TotalLeads = 
    CALCULATE(
        COUNTA('Lead'[emailaddress1]),
        FILTER('Lead',
            'Lead'[createdon].[Year] IN { currentYear }
        )
        
    )
    
    RETURN TotalLeads

createdon and conversiondate are date fields. 

 

Basically, there are cases in which the createdon field is for example, 15/12/2016, but the conversiondate field is 01/02/2017.

 

The way I tried to create the hierarchy is use the Month attribute from createdon to group by Month and to show both calculated measures in a Matrix.

 

My goal is to show "MU_Conversions_Affiliate_ThisYear" grouped per month with the relevant values, as well as MU_TotalLeads_Affiliate_ThisYear with the relevant values (each one with its own values).

 

I'm not sure how to achieve that.

 

 

Thank you in advance!

  • Hi,  I eventually found a solution by using USERELATIONSHIP after creating a separate relationship for each column.

     

    Thanks :).

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    analystict,

    Please share sample data of your table here and post expected result here.

    Regards,
    Lydia

    • analystict's avatar
      analystict
      Icon for Helper I rankHelper I

      Hi,  I eventually found a solution by using USERELATIONSHIP after creating a separate relationship for each column.

       

      Thanks :).