Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

How to change data model to do a custom matrix?

I have my Fact and a Project dimension:

Dimension Project:

ProjDiscountLevel1Level2Level3
1.05xyzxyzxyz
2.10xyzxyzxyz
3.10xyzxyzxyz
4.5xyzxyzxyz
5.8xyzxyzxyz
6.1xyzxyzxyz

 

 

Fact:

ProjClientGross FeesNet RevenueExpected RevenueDiff
1124320230,85-210,85
2152200046,81953,2
31411036,9-26,9
4234135170,5-135,5
521347126,844,2
62343430,63,4

 

 

Expected Revenue is a calculated column: Revenue[GrossFees] - ( RELATED(Project[Discount]) * Revenue[GrossFees] )

Diff is also a calculated column: Net Revenue - Expected Revenue

 

I need to achieve a matrix like:

    Diff
Client   -300
 Level1  -300
  Level2 0
   Level3-10
   Level3120
     
  Level2 -300
   Level3-300

 

 

Level2 is 0 if the sum of Level3 is positive... from Level2 and upwards it should just be a classic SUM of Level2.

 
How can I change my data model  to do this custom aggregation?

 

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    I need to do an agregattion across Project and Client table...

     

    I have my Fact and a Project dimension:

    Dimension Project:

    ProjDiscountLevel1Level2Level3
    1.05xyzxyzxyz
    2.10xyzxyzxyz
    3.10xyzxyzxyz
    4.5xyzxyzxyz
    5.8xyzxyzxyz
    6.1xyzxyzxyz

     

     

    Fact:

    ProjClientGross FeesNet RevenueExpected RevenueDiff
    1124320230,85-210,85
    2152200046,81953,2
    31411036,9-26,9
    4234135170,5-135,5
    521347126,844,2
    62343430,63,4

     

     

    Expected Revenue is a calculated column: Revenue[GrossFees] - ( RELATED(Project[Discount]) * Revenue[GrossFees] )

    Diff is also a calculated column: Net Revenue - Expected Revenue

     

    I need to achieve a matrix like:

        Diff
    Client   -300
     Level1  -300
      Level2 0
       Level3-10
       Level3120
         
      Level2 -300
       Level3    -300

     

     

    Level2 is 0 if the sum of Level3 is positive... from Level2 and upwards it should just be a classic SUM of Level2.

     
    How can I do this in DAX across the 2 dimensions? Do i need to change my data model  to do this custom matrix?

     

    • amitchandak's avatar
      amitchandak
      Icon for Super User rankSuper User

      Anonymous , Is you measure is ?

       

      sumx(Fact, [Net Revenue] - [Expected Revenue])

  • You should be able to use the ISINSCOPE function to help with this.
    A quick example...
    If you have data like

    you can add a calculated column 

    to get 

    you can then write a measure using ISINSCOPE

    and end up with 

    Your actual solution will depend greatly on how your data model is organized, but hopefully this gets you pointed in the right direction.