Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Data modeling- multiple subcategories in a dimension

I have a matrix visual which has under rows a Sector and then a Subcategory, both in the same dimension table. DimSector looks like this:

SectorSubSectorSector Key
Cash 1
GovernmentU.S. Treasury2
GovernmentAcency/Sovereigns3
CreditCorporate4
CreditMunicipals5
SecuritizedRMBS6

 

I then have a Fact table where I am doing the following DAX calculation. 

 

 

 

# Portfolio % = 
DIVIDE(
    [# Total_Market_Value_Base],
    CALCULATE(
        SUMX(FactPortfolioSectorDetails,[# Total_Market_Value_Base]),
        ALLSELECTED(FactPortfolioSectorDetails)
    )
)

# Total_Market_Value_Base = 
SUMX(FactPortfolioSectorDetails,[Market Value (Base)] + ([Accrued Interest] * [FX to Target]))

 

 

 

 

A scrubbed dataset with for FactPortfolioSectorDetails can be found here: https://docs.google.com/spreadsheets/d/1XIEuyCVwXE7pGR5YToK4S_dT9_prWkpQ/edit?usp=sharing&ouid=11467...

 

This is the visual.

  • Port % is [# Portfolio %] measure.
  • Sector is [Asset Type Subcategory] in FactPorfolioSectorDetails.
  • The subcategories of Sector are [Asset Type] in the fact table.
  • There is a slicer filtering the visual to display a single Account ID.

eloomis_0-1707434169951.png 

eloomis_1-1707434313167.png

 

When Government is minimized, it displays the correct value. When I expand it, it just divides the value for government in half instead of recalculating for each subsector. I need Portfolio % to calculate independently for each subsector grouping, and then calculate for the overall sector grouping. I'm not sure what I have wrong in my model to fix this.

 

I tried splitting Sector and Subsector to different dimension tables and having a key relating to FactPortfolioSectorDetails but this did not work. I also know that I have Sector and Subsector as values in my fact table, but I need to have a sector dimension to use in the visual, as there is another fact table in the schema which also will be supplying fields to this visual and need to be related with the dimension.

 

Any help is much appreciated.

 

For reference, here is a screenshot of the model.

eloomis_0-1707434829671.png

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I was able to fix the problem without modifying the measures - I made a mistake in merging the dimension keys with the fact tables. Thank you for the reponses!

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

I was able to fix the problem without modifying the measures - I made a mistake in merging the dimension keys with the fact tables. Thank you for the reponses!

Anonymous
Not applicable

Hi @Anonymous ,

 

I think you can try this code to create a measure.

# Portfolio % =
IF (
    ISINSCOPE ( DimSector[SubSector] ),
    DIVIDE (
        [# Total_Market_Value_Base],
        CALCULATE (
            SUMX ( FactPortfolioSectorDetails, [# Total_Market_Value_Base] ),
            FILTER (
                ALLSELECTED ( FactPortfolioSectorDetails ),
                FactPortfolioSectorDetails[Asset Type Subcategory] = MAX ( DimSector[Sector] )
            )
        )
    ),
    DIVIDE (
        [# Total_Market_Value_Base],
        CALCULATE (
            SUMX ( FactPortfolioSectorDetails, [# Total_Market_Value_Base] ),
            ALLSELECTED ( FactPortfolioSectorDetails )
        )
    )
)

vrzhoumsft_0-1707459345677.png

 

Best Regards,
Rico Zhou

 

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

 

amitchandak
Super User
Super User

@Anonymous , Switch measure based on level

 

# Portfolio % =
var _level1 = DIVIDE(
[# Total_Market_Value_Base],
CALCULATE(
SUMX(FactPortfolioSectorDetails,[# Total_Market_Value_Base]),
removefilters(FactPortfolioSectorDetails[Subsecor])
)
)

var _level2 = DIVIDE(
[# Total_Market_Value_Base],
CALCULATE(
SUMX(FactPortfolioSectorDetails,[# Total_Market_Value_Base]),
ALLSELECTED(FactPortfolioSectorDetails)
)
)

return
if(isinscope(FactPortfolioSectorDetails[Subsecor]), _level1, _level2)

 

 

How to Switch Subtotal and Grand Total in Power BI | Power BI Tutorials| isinscope: https://youtu.be/smhIPw3OkKA

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.