Power BI: create a monthly chart of a measure with 2 criteria
It is quite simple to create a monthly chart when my measure has a simple calculation but if my measure has 2 criteria to calculate the value, the chart is not displaying correctly. To do so, I have to add a monthly filter in my calculation. Let’s take an example. I have this simple measure:
COUNT('table'[argument])
Creating the monthly chart, it will look like that:
Now I have this measure with 2 conditions:
COUNTROWS(FILTER(ALLSELECTED('table'),'table'[argument1]="xxx" && 'table'[argument2]="xxx"))
Using the same chart, I will replace in the “values” field, “measure” by “measure 2”, and I get this:
Every month, the value is the same, of course, it may happen but in my example, it should not. The way to remediate, it is to add a monthly filter in my calculation for my “measure 2”:
CALCULATE(COUNTROWS(FILTER(ALLSELECTED('table'),'table'[argument1]="xxx" && 'table'[argument]="xxx2")),FILTER(ALLSELECTED('table'),'table'[argument3]=MAX('table'[argument3])))
And now, the chart is showing correctly.
Interesting Topics
-
Be successfully certified ITIL 4 Managing Professional
Study, study and study, I couldn’t be successfully certified without studying it, if you are interested...
-
Be successfully certified ITIL 4 Strategic Leader
With my ITIL 4 Managing Professional certification (ITIL MP) in the pocket, it was time to go for the...
-
Hide visual and change background color based on selection
Some small tricks to customize the background colour of a text box...
-
Stacked and clustered column chart or double stacked column chart
In excel, I use a lot the combination of clustered and stacked chart...