Forum Discussion

GanesaMoorthyGM's avatar
4 months ago
Solved

Share % Measure Logic tweak help

Hi guys,

So i was in a new requirement of converting excel report into power bi and i somehow fixed the template and finished.
excel template:

 

 Now i need your help in writing one particular measure

so this is how my matrix look like so now my share contribution logic is 
See we have btq age band 0-30 days etc.. and with MC band at top like <10% etc..

so for example here mc band <10% the btq age bad 0-30 days sale is 0.09 and the total sale in btq age band is 2.16 so 0.09/2.16 = 4%
this is the logic.
so i need your help in fixing this.
this is my sale measure name

All Country MTD Sales MC Band Exclusion 
thank you.

  • hi GanesaMoorthyGM 
    Can you try either of the below DAX. 

    Share % = 
    VAR CurrentCellSales = [All Country MTD Sales MC Band Exclusion]

    VAR RowTotalSales =
    CALCULATE(
    [All Country MTD Sales MC Band Exclusion],
    -- Replace 'fact_sales' with your actual dimension table name if this column doesn't live in the fact table
    REMOVEFILTERS( fact_sales[MakingCharge_Percent_Band] )
    )

    RETURN
    DIVIDE( CurrentCellSales, RowTotalSales, 0 )

    Share % = 
    VAR CurrentSales = [All Country MTD Sales MC Band Exclusion]
    
    VAR RowTotalSales = 
        CALCULATE (
            [All Country MTD Sales MC Band Exclusion],
            // This removes the filter from the Matrix columns to get the Row Total
            ALLSELECTED ( 'YourTable'[MakingCharge_Percent_Band] )
        )
    
    RETURN
        DIVIDE ( CurrentSales, RowTotalSales, 0 ) 

     Use ALLSELECTED instead of REMOVEFILTER, If you ever apply a slicer to the page that limits the MakingCharge_Percent_Band to only a few specific bands and you want the row total to only reflect the selected bands rather than the entire database. 

     

    if this solves your problem, please mark this as solution and give a kudos.
    @me so that I don't lose this thread.

7 Replies

  • hi GanesaMoorthyGM 
    Can you try either of the below DAX. 

    Share % = 
    VAR CurrentCellSales = [All Country MTD Sales MC Band Exclusion]

    VAR RowTotalSales =
    CALCULATE(
    [All Country MTD Sales MC Band Exclusion],
    -- Replace 'fact_sales' with your actual dimension table name if this column doesn't live in the fact table
    REMOVEFILTERS( fact_sales[MakingCharge_Percent_Band] )
    )

    RETURN
    DIVIDE( CurrentCellSales, RowTotalSales, 0 )

    Share % = 
    VAR CurrentSales = [All Country MTD Sales MC Band Exclusion]
    
    VAR RowTotalSales = 
        CALCULATE (
            [All Country MTD Sales MC Band Exclusion],
            // This removes the filter from the Matrix columns to get the Row Total
            ALLSELECTED ( 'YourTable'[MakingCharge_Percent_Band] )
        )
    
    RETURN
        DIVIDE ( CurrentSales, RowTotalSales, 0 ) 

     Use ALLSELECTED instead of REMOVEFILTER, If you ever apply a slicer to the page that limits the MakingCharge_Percent_Band to only a few specific bands and you want the row total to only reflect the selected bands rather than the entire database. 

     

    if this solves your problem, please mark this as solution and give a kudos.
    @me so that I don't lose this thread.

  • Hi GanesaMoorthyGM,

     

    Try Below Measure

     

    Share % =
    DIVIDE(
    [All Country MTD Sales MC Band Exclusion],
    CALCULATE(
    [All Country MTD Sales MC Band Exclusion],
    REMOVEFILTERS('MC Band')
    )
    )

     

    ๐ŸŒŸ I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
    ๐Ÿ’ก Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
    ๐ŸŽ– As a proud SuperUser and Microsoft Partner, weโ€™re here to empower your data journey and the Power BI Community at large.
    ๐Ÿ”— Curious to explore more? [Discover here].
    Letโ€™s keep building smarter solutions together!

    • GanesaMoorthyGM's avatar
      GanesaMoorthyGM
      Helper II

      Hi. Thanks for the quick response

      All Country MC Band Sales Share % =
      DIVIDE(
      [All Country MTD Sales MC Band Exclusion],
      CALCULATE(
      [All Country MTD Sales MC Band Exclusion],
      REMOVEFILTERS('fact_sales'[MakingCharge_Percent_Band])
      )
      )i used this this results in 100% for all
       
  • v-ssriganesh's avatar
    v-ssriganesh
    Community Support

    Hello GanesaMoorthyGM,

    We hope you're doing well. Could you please confirm whether your issue has been resolved or if you're still facing challenges? Your update will be valuable to the community and may assist others with similar concerns.

    Thank you.

  • v-ssriganesh's avatar
    v-ssriganesh
    Community Support

    Hello GanesaMoorthyGM

    Could you please confirm if your query has been resolved by the provided solutions? This would be helpful for other members who may encounter similar issues.

     

    Thank you for being part of the Microsoft Fabric Community.