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
praveenlc
Helper I
Helper I

find weekly variance of heirarchy measure at category level and sub-category

Hello, I am trying to find weekly varaince at each category level and sub-category level (CurrentWeek-PreviousWeek)/PreviousWeek

The challange is when I hide 0 values from the metrix table the calculation gives different results, I have used FILTER(), ISINSCOPE() and ALLEXCEPT to achieve the measures

 

In my example:

- for category 'cbf-cloudservices-prd' previous week=6770.06 and current week=1182.48 and varaince is -82.53%

- but when I apply variance <> blank(), then the values change to subcategory values (4613.13, 745.20, 83.85%)

 

attaching the image and dax measure, could someone please help me undertand fix the problem.

IMG2.JPGIMG3.JPG

MEASURE1:_CurrWeek AZ cost= SWITCH(TRUE(), ISINSCOPE('df Usage'[MeterCategory]),
CALCULATE (
    [Azure Cost],
    FILTER (
        ALL ( MasterCalendar ),
                 MasterCalendar[YearWeek]= MAX ( MasterCalendar[YearWeek] )
    ))
, ISINSCOPE(SingleSourceOfTruth_Actuals[SubscriptionName]),
CALCULATE (
    [Azure Cost],
    FILTER (
        ALL ( MasterCalendar ),
MasterCalendar[YearWeek]= MAX ( MasterCalendar[YearWeek] )
    ),ALLEXCEPT(SingleSourceOfTruth_Actuals,SingleSourceOfTruth_Actuals[SubscriptionName])),0)
MEASURE2:_PrevWeek AZ cost1 = SWITCH(TRUE(), ISINSCOPE('df Usage'[MeterCategory]),
CALCULATE (
    [Azure Cost],
    FILTER (
        ALL ( MasterCalendar ),
           MasterCalendar[YearWeek] = MAX ( MasterCalendar[YearWeek] ) - 1))
, ISINSCOPE(SingleSourceOfTruth_Actuals[SubscriptionName]),
CALCULATE (
    [Azure Cost],
    FILTER (
        ALL ( MasterCalendar ),
            MasterCalendar[YearWeek] = MAX ( MasterCalendar[YearWeek] ) - 1
    ),ALLEXCEPT(SingleSourceOfTruth_Actuals,SingleSourceOfTruth_Actuals[SubscriptionName])),0)
MEASURE3VARIANCE:_Weekly Variance Azure Cost 1 % =
IF (
    [_CurrWeek AZ cost] > 500
        || ([_CurrWeek AZ cost] > [_PrevWeek AZ cost1]
        && [_PrevWeek AZ cost1] > 200),
    DIVIDE (
        [_CurrWeek AZ cost]-[_PrevWeek AZ cost1],
        CALCULATE([_PrevWeek AZ cost1]),0))

 

3 REPLIES 3
v-xuxinyi-msft
Community Support
Community Support

Hi @praveenlc 

 

Can you provide the exact data and data structure? How to provide sample data in the Power BI Forum - Microsoft Fabric Community

We can better understand the problem and help you. Or Show them as screenshots. Please remove any sensitive data in advance.

 

Best Regards,
Community Support Team _Yuliax

 

praveenlc
Helper I
Helper I

how do I exclude the blank rows (red marked) without changing the yellow highlighted category values, filters on subcategory should not effect the values from category
IMG4.JPG

praveenlc
Helper I
Helper I

any help would be greatly appreciated, please let me know if any more details required

 

Thanks in advance

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.