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
ovonel
Post Prodigy
Post Prodigy

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 3
ovonel
Post Prodigy
Post Prodigy

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?

 

@ovonel , Is you measure is ?

 

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

jgeddes
Super User
Super User

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

jgeddes_0-1669669925495.png

you can add a calculated column 

jgeddes_1-1669669961481.png

to get 

jgeddes_2-1669669974754.png

you can then write a measure using ISINSCOPE

jgeddes_3-1669670041451.png

and end up with 

jgeddes_4-1669670065457.png

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




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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.