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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
analystict
Helper I
Helper I

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!

1 ACCEPTED SOLUTION

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

 

Thanks :).

View solution in original post

2 REPLIES 2
v-yuezhe-msft
Employee
Employee

@analystict,

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

Regards,
Lydia

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

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

 

Thanks :).

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.