Forum Discussion

JordanJackson's avatar
JordanJackson
Icon for Advocate II rankAdvocate II
3 years ago

DAX measure giving the wrong answer / different answer when in a table compared to a bar chart

I've written to following DAX measure to calculate the current energy system type from different sites:

Latest System Types Countx (4) =
CALCULATE(
    COUNTX('Sites_Energy_and_Water', 'Sites_Energy_and_Water'[Type of System]),
    FILTER(
        'Sites_Energy_and_Water',
        'Sites_Energy_and_Water'[DateofRecording] = MAX('Sites_Energy_and_Water'[DateofRecording])
    )
)
 
I've tried with just COUNT and then COUNTX in order to resolve the issue. When I place this measure into a bar visual it only given me 5 results:

But in the data source and when the measure is in a table it shows that there are 7 entries when following the slicers, yet the total is wrong on here also.

 


I am aware that this would be something to do with the way that total values are calculated but I was under the impression that COUNTX would then resolve this issue?

Any help with this would be greatly appreciated!

2 Replies

    • JordanJackson's avatar
      JordanJackson
      Icon for Advocate II rankAdvocate II
      System Type Measure Region Contract Satalite Name
      Generator + Battery 1 E A  
      Generator + Battery 1 E A 2
      Generator + Battery 1 E B 1
      Generator + Battery + Solar 1 E B 2
      Generator + Battery + Solar 1 E C 1
      Generator + Battery + Solar 1 E D 1
      Hydrogen + Battery 1 E E 1


      Am I needing to add in the Satalite Name context to the measure?