Forum Discussion

JayKarim's avatar
JayKarim
Frequent Visitor
4 years ago
Solved

Measures, new columns for separate YOAs

Hi Power BI community,   I have a data table with the following 3 fields:   Product Total Sales £ Year Paid (2019,2020,2021)   1. How do i create a measure to seprate YOA data for 2019, 202...
  • BA_Pete's avatar
    4 years ago

    Hi JayKarim ,

     

    The way you would normally display this in Power BI is by creating a generic measure:

    _sales = SUM(yourTable[Total Sales £])

    You would then differentiate between years/products etc. by adding these columns into your visual that displays your measure. Power BI will handle the context filtering to correctly sum your sales in each of the different year/product groups. If you only want to show one year in each visual, then apply a visual or page-level filter that specifies the year required. This keeps coding and maintenance to a minimum.

     

    If you REALLY want a separate measure for each year, you would create measures something like this:

    _sales2019 =
    CALCULATE(
      SUM(yourTable[Total Sales £]),
      yourTable[Year Paid] = "2019"
    )

     

    Pete