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
andybamber
Helper III
Helper III

Row Context Issues

Hello Everyone!

 

Hoping someone can help... its a context thing, but i just cant work it out! Attached is a data set which shows the issue...

 

Essentially i am calculating the difference in Resources between current data snapshot date and a snapshot from 4 weeks ago.

 

When i display the data just as Totals the numbers are correct. As an example Domain E1 has a total net change of 3. When i then expand that to CC level i see the CC where the changes are... in this case CC5042-US, but it also brings in CC5465-US, which when you look at the data set is not part of any of the 2 snapshots (10th Nov and 8th Dec)... how i can create the mneasure so that it maintains context down to the CC level?

 

PowerBI Report 

 

Thanks, Andy

1 ACCEPTED SOLUTION
AntrikshSharma
Community Champion
Community Champion

@andybamber See if this is the desired result:

 

The file is attached below my signature.

 

1.png

Measure = 
VAR MaxDate = CALCULATE ( MAX ( Resource[snaphot_stamp] ), ALL ( Resource ) )
VAR CurrentWeekAmount = 
    CALCULATE (  
        DISTINCTCOUNT ( Resource[resource_key] ),
        Resource[snaphot_stamp] = MaxDate
    )
VAR LastWeekAmount = 
    CALCULATE (  
        DISTINCTCOUNT ( Resource[resource_key] ),
        Resource[snaphot_stamp] = MaxDate - 28
    )
VAR Result = 
    CurrentWeekAmount - LastWeekAmount
RETURN
    Result

View solution in original post

2 REPLIES 2
andybamber
Helper III
Helper III

@AntrikshSharma  thats perfect! so easy when you see it! thanks, Andy

AntrikshSharma
Community Champion
Community Champion

@andybamber See if this is the desired result:

 

The file is attached below my signature.

 

1.png

Measure = 
VAR MaxDate = CALCULATE ( MAX ( Resource[snaphot_stamp] ), ALL ( Resource ) )
VAR CurrentWeekAmount = 
    CALCULATE (  
        DISTINCTCOUNT ( Resource[resource_key] ),
        Resource[snaphot_stamp] = MaxDate
    )
VAR LastWeekAmount = 
    CALCULATE (  
        DISTINCTCOUNT ( Resource[resource_key] ),
        Resource[snaphot_stamp] = MaxDate - 28
    )
VAR Result = 
    CurrentWeekAmount - LastWeekAmount
RETURN
    Result

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.

Top Solution Authors