Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Stacked Column Chart Showing Incorrect Totals

I am making a stacked column chart using conditional filtering based on a count of incidents, where if on a given day, there's an incident, the day shows up as red.

 

I created concatenates of the date and event ID in Power Query to have similar references for each table. They are not themselves related, but they each have the same parent customer table and are both related to my calendar table. I then created a column in my Daily Tracking Table to count how many incidents a day there were for each customer.

 

Event Count = Var Events =
CALCULATE(
COUNTA(EventTable[DateEventId]),
FILTER(ALL(EventTable),EventTable[DateEventId] = DailyTable[DateEventId]))
RETURN
IF(ISBLANK(Events), 0, Events)
 
By looking at each value independently in the two tables, it tracks correctly and has the right count for each date. However, when I use the Event Count column in my stacked column chart, the values don't match up.
 
For a given date, this is what the correct count looks in my Daily Table:
 
CustomerIDDateEvent Count

1

2/6/200
22/6/201
32/6/200
42/6/201
52/6/200
62/6/200
72/6/200
82/6/200
92/6/201

 

The total number of events for this in a given visualization should be 3.

 

When I put it into the table to verify the total is correct (default to Sum), I instead get this result. 

 

Capture.PNG

 

I have the visualization summing the Event Count, and when I switch it to Max, I get 6 for some reasons.

 

Guess I'm trying to figure out why the visualization isn't summing the events correctly? Is it something in how I calculated the column in the first place that is causing this to be incorrect? Any help would be much appreciated!

1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can use the following measure to meet your requirement.

 

Event Count =
SUMX (
    VALUES ( CustomerID ),
    VAR Events =
        CALCULATE (
            COUNTA ( EventTable[DateEventId] ),
            FILTER ( ALL ( EventTable ), EventTable[DateEventId] = DailyTable[DateEventId] )
        )
    RETURN
        IF ( ISBLANK ( Events ), 0, Events )
)

 

We create a sample maybe you can refer.

The measure in our sample like this,

Event Count =
SUMX(
    VALUES(EventTable[CustomerID]),
    Var Events =
    CALCULATE(
        COUNTA(EventTable[CustomerID]))
    RETURN
        IF(EventTable[CustomerID]=9,0,Events)
)
 

39.png

 

BTW, pbix as attached.

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can use the following measure to meet your requirement.

 

Event Count =
SUMX (
    VALUES ( CustomerID ),
    VAR Events =
        CALCULATE (
            COUNTA ( EventTable[DateEventId] ),
            FILTER ( ALL ( EventTable ), EventTable[DateEventId] = DailyTable[DateEventId] )
        )
    RETURN
        IF ( ISBLANK ( Events ), 0, Events )
)

 

We create a sample maybe you can refer.

The measure in our sample like this,

Event Count =
SUMX(
    VALUES(EventTable[CustomerID]),
    Var Events =
    CALCULATE(
        COUNTA(EventTable[CustomerID]))
    RETURN
        IF(EventTable[CustomerID]=9,0,Events)
)
 

39.png

 

BTW, pbix as attached.

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.