Forum Discussion

bv27718n's avatar
bv27718n
Helper II
5 years ago

Help, how d I get % change?

Hi

I am new to power BI and have two issues:

I have to different data sets, one for 2020 and one for 2021. How can I show the percent change for each row?

 

Additionally in my data query, I have states in a column, I need to move these in order to break out the states by region not just all states? Problem is when I move the data it changes all my other data fields? I attached photos. I want to do membership the same way but be able to put different states by region in my visuals. Thanks so much!

 

 

17 Replies

  • richbenmintz's avatar
    richbenmintz
    Resident Rockstar

    Hi bv27718n,

     

    Couple Suggestions:

    1. Create a Region table that contains the State and Region it belongs to, then join that table to your facts, use the Region table to filter the fact data

    2. Either Union your 2020 and 2021 data together and add a period column, more extensible as you add more periods || or created calc columns using lookups in the 2021 table to get the 2020 data you want to compare for each row, not as extensible for additional years.

     

    If you are able to provide sample data as opposed to screen shots that would be very helpful.

     

    Thanks, 

    • bv27718n's avatar
      bv27718n
      Helper II

      Hi,

       

      I am still confused. not sure what to do. how can I share data here? Thanks!!

      • richbenmintz's avatar
        richbenmintz
        Resident Rockstar

        Hi bv27718n,

         

        you can copy and paste the data into a table in the thread, or you can share a pbix through onedrive or google drive

  • StatePF LifePF PatronPF Gold Patron 21PF Elite Mbrs 2021QF LifeQF PatronQF Gold PatronQF Elite MbrsPF/QF Gold Patron 21PF/QF Patron 21PF/QF Life 21

    AK20002000000020
    AL1440181950240933
    AR1401151800181032
    AZ7931831900191398
    CA1083011113001303121
    CO2637327318011947281
    CT17001710010018
    DE800820020010
    FL75207728613518103
    GA42104360606607102
    HI40040000004
    IA645204669390039420684
    ID46104730030149
    IL3387134640004017378
    IN1560015616101701172
    KS2374124245535349282
    KY1700171400140031
    LA10001020020012
    MA15001500000015
    MD31003150050036
    ME70071001008
    MI31011132281110212318
    MN1378559144242214510571420
    MO86218976307915162
    MS16001680080024
    MT16611168400411170
    NC3410351800180152
    ND22010221000001220
    NE345243372215026329366
    NH80080101018
    NJ12001210010013
    NM13001330030016
    NV29002930030032
    NY40104141050244
    OH20880216143017011222
    OK2100215220540273
    OR47004750050052
    PA11800118500500123
    RI20020000002
    SC1621191430171530
    SD49914145271011121515509
    TN3940433020320669
    TX12291132115133131422237
    UT30003010010031
    VA3901401110121150
    VT30250112313
    WA11120113300302114
    WI36493376112013311375
    WV700730030010
    WY73107400000173
    • richbenmintz's avatar
      richbenmintz
      Resident Rockstar

      Hi bv27718n ,

       

      Please Share your pbix file, or an excel copy of the data, the data you have pasted does not import properly into Power BI

  • Are you able to create custom look up, to do the calc between two different data sets? I have one for membership 5.20 and 5.21, would you just link in order to see percent change for each?

    • richbenmintz's avatar
      richbenmintz
      Resident Rockstar

      Hi bv27718n,

       

      Looking at your file, you do not need the relationship between the Elite 20 and 21 tables.

      Below is a formula that will create a new column in your table with the other tables value

      PF Life 2020 col = 
      VAR _state = 'Elite 5.21'[State]
      return 
      CALCULATE(MAX('Elite 5.20'[PF life]), FILTER('Elite 5.20', 'Elite 5.20'[State] = _state))

       

      you can then create the following measures to get the sums and variance

      PF Life 2020 = SUM('Elite 5.21'[PF Life 2020 col])
      
      pf life 2020 var = sum('Elite 5.21'[PF Life]) - sum('Elite 5.21'[PF Life 2020 col])

      Result would look like this

       

      I have attached your file with my mods

       

      To slice by Region, you will need to create a region table that contains each state and region then relate the table to the fact tables on the state. You will then use the the region to filter and slice your data.

       

      Please review the following Microsoft docs for best practices for data modelling

      https://docs.microsoft.com/en-us/power-bi/guidance/star-schema 

       

      I would also suggest that you store your facts in a single fact table with a period column to define the period that the fact belongs to rather than creating tables for each year, it is not a manageble or extensible solution.

       

      Thanks,

       

      • bv27718n's avatar
        bv27718n
        Helper II

        Okay, makes sense. I appreciate your help. I did have one last follow up, I am looking at what you did, how do you then add in the other colums likethe PF 2020? I would go into the elite 2020, create columns say for gold patron and patron and then go from there I take it.

         

        Is there an easy way to create a "state region" table? where is that created? 

    • bv27718n's avatar
      bv27718n
      Helper II

      Awesome, thanks! So, I just continue to do that and I can add in a percent change column as well. How come you do not need the relationship there? I thought you did. 

       

       

      • richbenmintz's avatar
        richbenmintz
        Resident Rockstar

        Hi bv27718n,

         

        The Facts really are not related, you could have related on State 1 to 1 but that was not the case

  • I dont think I can create a custom colum to pull in the calcs but the data sets I am using are on seperate pagesthough. right?

  • v-henryk-mstf's avatar
    v-henryk-mstf
    Community Support

    Hi bv27718n ,

     

    Sorry, I don’t understand your needs. Can you describe it more accurately? It’s best to provide a screenshot of the desired result. I will answer you as soon as possible.

     

    Best Regards,
    Henry