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
Anonymous
Not applicable

Changing displayed meaures as user drills down within Matrix?

Hello,

 

I need to show sales by a date hierarchy (year > month > day) which displays different measures depending upon the level of the hierarchy the user drills to within a matrix. Is this possible?

 

I have currently set this up across 3 different matrix objects.

 

So the yearly view

Policy Count Change vs Prev Year = sum('LGIDW SOP'[Policy Volume]) - CALCULATE(sum('LGIDW SOP'[Policy Volume]), filter( all('System Submitted Date'), 'System Submitted Date'[Calendar YearNumber] = max('System Submitted Date'[Calendar YearNumber])-1))

 

% Policy Count Change vs Prev Year = divide([Policy Count Change vs Prev Year], [Total Policy Count])

 

Monthly

Policy Count Change vs Prev Month = sum('LGIDW SOP'[Policy Volume]) - CALCULATE(sum('LGIDW SOP'[Policy Volume]), filter( all('System Submitted Date'), 'System Submitted Date'[Calendar Year] = max('System Submitted Date'[Calendar Year]) && 'System Submitted Date'[Calendar MonthNumber] = max('System Submitted Date'[Calendar MonthNumber])-1 ))

 

% Policy Count Change vs Prev Month = divide([Policy Count Change vs Prev Month], [Total Policy Count])

 

Weekly

Policy Count Change vs Prev Week = sum('LGIDW SOP'[Policy Volume]) - CALCULATE(sum('LGIDW SOP'[Policy Volume]), filter( all('System Submitted Date'), 'System Submitted Date'[Calendar Year] = max('System Submitted Date'[Calendar Year]) && 'System Submitted Date'[Calendar WeekNumber] = max('System Submitted Date'[Calendar WeekNumber])-1 && 'System Submitted Date'[WeekDayNumber] = max('System Submitted Date'[WeekDayNumber])))

 

% Policy Count Change vs Prev Week = divide([Policy Count Change vs Prev Week], [Total Policy Count])

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

We can use HASONEVALUE to identify the context. The formula below is based on your data here. Please try it out.

New Measure =
IF (
    HASONEVALUE ( 'System Submitted Date'[WeekDayNumber] ),
    SUM ( 'LGIDW SOP'[Policy Volume] )
        - CALCULATE (
            SUM ( 'LGIDW SOP'[Policy Volume] ),
            FILTER (
                ALL ( 'System Submitted Date' ),
                'System Submitted Date'[Calendar Year]
                    = MAX ( 'System Submitted Date'[Calendar Year] )
                    && 'System Submitted Date'[Calendar WeekNumber]
                        = MAX ( 'System Submitted Date'[Calendar WeekNumber] ) - 1
                    && 'System Submitted Date'[WeekDayNumber]
                        = MAX ( 'System Submitted Date'[WeekDayNumber] )
            )
        ),
    IF (
        HASONEVALUE ( 'System Submitted Date'[Calendar MonthNumber] ),
        SUM ( 'LGIDW SOP'[Policy Volume] )
            - CALCULATE (
                SUM ( 'LGIDW SOP'[Policy Volume] ),
                FILTER (
                    ALL ( 'System Submitted Date' ),
                    'System Submitted Date'[Calendar Year]
                        = MAX ( 'System Submitted Date'[Calendar Year] )
                        && 'System Submitted Date'[Calendar MonthNumber]
                            = MAX ( 'System Submitted Date'[Calendar MonthNumber] ) - 1
                )
            ),
        IF (
            HASONEVALUE ( 'System Submitted Date'[Calendar YearNumber] ),
            SUM ( 'LGIDW SOP'[Policy Volume] )
                - CALCULATE (
                    SUM ( 'LGIDW SOP'[Policy Volume] ),
                    PREVIOUSYEAR ( 'System Submitted Date'[Calendar date] )
                )
        )
    )
)

Best Regards,

Dale

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

View solution in original post

2 REPLIES 2
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

We can use HASONEVALUE to identify the context. The formula below is based on your data here. Please try it out.

New Measure =
IF (
    HASONEVALUE ( 'System Submitted Date'[WeekDayNumber] ),
    SUM ( 'LGIDW SOP'[Policy Volume] )
        - CALCULATE (
            SUM ( 'LGIDW SOP'[Policy Volume] ),
            FILTER (
                ALL ( 'System Submitted Date' ),
                'System Submitted Date'[Calendar Year]
                    = MAX ( 'System Submitted Date'[Calendar Year] )
                    && 'System Submitted Date'[Calendar WeekNumber]
                        = MAX ( 'System Submitted Date'[Calendar WeekNumber] ) - 1
                    && 'System Submitted Date'[WeekDayNumber]
                        = MAX ( 'System Submitted Date'[WeekDayNumber] )
            )
        ),
    IF (
        HASONEVALUE ( 'System Submitted Date'[Calendar MonthNumber] ),
        SUM ( 'LGIDW SOP'[Policy Volume] )
            - CALCULATE (
                SUM ( 'LGIDW SOP'[Policy Volume] ),
                FILTER (
                    ALL ( 'System Submitted Date' ),
                    'System Submitted Date'[Calendar Year]
                        = MAX ( 'System Submitted Date'[Calendar Year] )
                        && 'System Submitted Date'[Calendar MonthNumber]
                            = MAX ( 'System Submitted Date'[Calendar MonthNumber] ) - 1
                )
            ),
        IF (
            HASONEVALUE ( 'System Submitted Date'[Calendar YearNumber] ),
            SUM ( 'LGIDW SOP'[Policy Volume] )
                - CALCULATE (
                    SUM ( 'LGIDW SOP'[Policy Volume] ),
                    PREVIOUSYEAR ( 'System Submitted Date'[Calendar date] )
                )
        )
    )
)

Best Regards,

Dale

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

@v-jiascu-msft thank you! I have came across that function previously but never had the chance to use it.

 

That works really well!

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.