Forum Discussion

hoa3nok7's avatar
hoa3nok7
Frequent Visitor
4 years ago
Solved

Switching Signs in Power BI

Hi everyone,   My data is like this. Each group has corresponding amount and I only flip the amount for group A and B, but keep the sign for C and D the same.   FY Period Grouping Amount F...
  • jennratten's avatar
    4 years ago

    Hello - I recommend you add a mapping table that indicates the desired flip behavior and then relate it to the fact table and incorporate it into your calculation.  

     

    GroupingFlip Behavior
    A-1
    B-1
    C1
    D1
  • v-angzheng-msft's avatar
    4 years ago

    Hi, hoa3nok7 

    In this case, I think the flipped amount column is not necessary.
    You can use the ISINSCOP function to calculate the total separately.

    Modify the above measures as follows:

     

    Measure =
    VAR _SUM_AB =
        CALCULATE (
            SUM ( 'Table1'[Amount] ),
            FILTER ( 'Table1', 'Table1'[FISCAL_YEAR] = [Selected Fiscal Year] ),
            FILTER ( 'Table1', 'Table1'[PERIOD] <= [Selected Period] ),
            FILTER ( 'Table1', 'Table1'[Grouping] = "A" || 'Table1'[Grouping] = "B" )
        )
    VAR _SUM_CD =
        CALCULATE (
            SUM ( 'Table1'[Amount] ),
            FILTER ( 'Table1', 'Table1'[FISCAL_YEAR] = [Selected Fiscal Year] ),
            FILTER ( 'Table1', 'Table1'[PERIOD] <= [Selected Period] ),
            FILTER ( 'Table1', 'Table1'[Grouping] = "C" || 'Table1'[Grouping] = "D" )
        )
    VAR _SUM_ALL =
        CALCULATE (
            SUM ( 'Table1'[Amount] ),
            FILTER ( 'Table1', 'Table1'[FISCAL_YEAR] = [Selected Fiscal Year] ),
            FILTER ( 'Table1', 'Table1'[PERIOD] <= [Selected Period] )
        )
    RETURN
        IF (
            ISINSCOPE ( 'Table'[Grouping] ),
            // 1,
            - ( _SUM_AB ) + _SUM_CD,
            // 2
            - ( _SUM_ALL )
        )
    

     

    If this doesn't work, could you please consdier sharing more details about it and posting expected result so it is clear on what needs to be implemented?  And It would be great if there is a sample file without any sesentive information here. It makes it easier to give you a solution.

     

     

    Best Regards,
    Community Support Team _ Zeon Zheng


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