Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

SUM unique values from filtered table

Hello, everyone! I am new in Power BI, and I haven't been able to start my dataviz because I'm stuck with the data transformation. 

 

I have a data set that is essentially this. 

 

 

I have a "nested" product list with "repeated" information about the stores. If you see, I have different stores in each country, but the values from Store Class and Employees are the same information for the same store ID. 

The Store ID is unique, regardless of the country.

The Store Class is not unique. 

 

What I need to calculate is the total number of employees in different scenarios. 

  • Total employees per country
  • Total employees per store class per country 

For example, I manually calculated the values from Luxembourg in Excel and this is how I would want to calculate the values automatically in Power BI

Total employees per country: 98

Total employees per country per store class: 

  • Class A: 50
  • Class B: 25
  • Class C: 3
  • Class 😧 20

 

I am trying to calculate this as either another column and this would give me repeated values.  Or as a measure, that I can then use in my data visualization as a Card with a filter. 

 

Any help will be much appreciated!  

5 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      This is the sample table I have 😄 

       

      CountryStore IDStore ClassEmployeesProductsTotal employees per country Total employees per country per store class
      Luxembourg12A5Rice9850
      Luxembourg12A5Beans9850
      Luxembourg543B25Cucumber9825
      Luxembourg543B25Rice9825
      Luxembourg543B25Beans9825
      Luxembourg4757A45Rice9850
      Luxembourg4757A45Tomatoes9850
      Luxembourg23C3Tomatoes983
      Luxembourg23C3Beans983
      Luxembourg23C3Chicken983
      Luxembourg224D20Beans9820
      Luxembourg224D20Pasta9820
      Germany357A32Cucumber  
      Germany357A32Rice  
      Germany357A32Beans  
      Germany2356A6Rice  
      Germany2356A6Tomatoes  
      Germany2356A6Chicken  
      Germany2356A6Beans  
      Germany9D8Rice  
      Germany9D8Tomatoes  
      Germany9D8Chicken  
      Germany9D8Beans  
      Germany9D8Cucumber  
      Germany9D8Pasta  
      Germany97B54Lemon  
      Germany97B54Beans  
      Germany97B54Cucumber  
      France23C5Cucumber  
      France23C5Beans  
      France23C5Lemon  
      France23C5Pasta  
      France568A23Carrots  
      France568A23Chicken  
      France568A23Pasta  
      France568A23Lemon  
      France568A23Coriander  
      France568A23Beans  
      France67A9Chicken  
      France67A9Pasta  
      France67A9Carrots  
      France3267D49Chicken  
      France3267D49Pasta  
      France3267D49Lemon  
      France3267D49Coriander  
      France3267D49Beans  
      France111A27Chicken  
      France111A27Pasta  
      France111A27Lemon  
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi smpa01 this helps for this simple data set, indeed. 

     

    The problem is that my actual dataset has thousands of "Countries" (I know there are not thousands of countries, but I changed the field names to share the dataset structure haha)

     

    I was hoping to get a way to calculated with DAX measures so that I can then add Card visualizations with a slicer to select the Country I want to see or the class of store I want to see or both. 

     

    Do you know any solution for this? 

    Thanks a lot! 

    • v-easonf-msft's avatar
      v-easonf-msft
      Icon for Community Support rankCommunity Support

      Hi, Anonymous 

      It looks like [base] measure created by smpa01  can meet your needs. I didn't find any error in his measure. The card can be filtered properly. Please recheck it.

       

       

       

      If I have misunderstood,  please explain your needs in more detail.

       

      Best Regards,
      Community Support Team _ Eason