Forum Discussion

gkakun's avatar
gkakun
Helper III
7 years ago
Solved

Countif in powerbi

Hi all,   Need some help calculating the month of use.  I have part number column and 12 additional columns for consumption for each month.  For example, Part number X1234 and the consumption in ...
  • TheOckieMofo's avatar
    7 years ago

    Your first issue is the shape of your data. The data engine for Power BI is Power Pivot. This is a column-based database, essentially. So, you would first need to "un-pivot" your data via Power Query ("Get Data" in power BI) so that you would go from having a 13 column table to a three column table with Part number, month, and value. 

     

    Once you've done that, you could write a dax measure to do the count for you. Here I'll need to defer to some dax ninjas in the group. But it would likely involve a variable that would countrows on a dax query, then wrapping a count function in a calculate with that variable equals 1. If I can find an example of the formula, i'll update this post.