Forum Discussion

hidenseek9's avatar
hidenseek9
Post Patron
6 years ago
Solved

Data allocation within Power BI

Hello Power BI community   I have a question on how to allocate % of data within Power BI. Please find below as a sample data I created.  Sample Data    What I have is a dataset showing a month...
  • v-alq-msft's avatar
    v-alq-msft
    6 years ago

    Hi, hidenseek9 

     

    The sample data 2 link is not available. You may try to modify the calculated table and the measure as follows.

     

    calculated table:
    ModifiedCategory = 
    UNION(
        Category,
        DATATABLE("Store",STRING,"Segment",STRING,{{"Avocado","Fruits"}}),
        DATATABLE("Store",STRING,"Segment",STRING,{{"Orange","Vegetables"}}),
        DATATABLE("Store",STRING,"Segment",STRING,{{"Cucumber","Animals"}})
    )
    
    measure:
    Sales = 
    SUMX (
            'ModifiedCategory',
            VAR s = [Store]
            VAR e = [Segment]
            RETURN
                SWITCH (
                    TRUE (),
                    s = "Avocado"
                        && e = "Vegetables", CALCULATE ( SUM ( 'Data'[Gross Sales] ), 'Data'[Store] = s ) * 0.9,
                    s = "Avocado"
                        && e = "Fruits", CALCULATE (
                        SUM ( 'Data'[Gross Sales] ),'Data'[Store] = s
                    ) * 0.1,
                    s = "Orange"
                        && e = "Vegetables", CALCULATE ( SUM ( 'Data'[Gross Sales] ), 'Data'[Store] = s ) * 0.25,
                    s = "Orange"
                        && e = "Fruits", CALCULATE (
                        SUM ( 'Data'[Gross Sales] ),'Data'[Store] = s
                    ) * 0.75,
                    s = "Cucumber"
                        && e = "Vegetables", CALCULATE ( SUM ( 'Data'[Gross Sales] ), 'Data'[Store] = s ) * 0.95,
                    s = "Cucumber"
                        && e = "Animals", CALCULATE (
                        SUM ( 'Data'[Gross Sales] ),'Data'[Store] = s
                    ) * 0.05,
                    CALCULATE ( SUM ( 'Data'[Gross Sales] ), 'Data'[Store] = s )
                )
        )

     

     

     

    Best Regards

    Allan

     

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