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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
FrancaZ
Regular Visitor

Counting two different columns on the same X-axis without prior aggregation

My Data:
Table1 with columns "ID", "Creation Week", and "Closure Week", e.g. 

IDCreation WeekClosure Week
12004-012004-01
22004-012004-02
32004-022004-02
42004-032004-03

 

My Goal:

I want a visual with the weeks on the X-axis counting IDs created in that week (one bar) and IDs closed in that week (another bar). Hence, for the above data, output should be like:

| x   |   o |     | 

| xo | xo | xo |

--------------

  01  02   03        (x = created, o = closed)

 

My Challenge:

I can easily get this done if I user Power Query to aggregate before, but I want to to have another visual which is linked and displaying the details, i.e. more or less the original table which should be filtered if I click on one of the bars. This works also fine if I just make that char for created or for closed, but anyone an idea how to get that working with both in the same visual?

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@FrancaZ,

 

This solution requires a Weeks table consisting of each possible week. You can create this in Power Query or DAX. This table has no relationship with the data table. Here's a DAX calculated table (I renamed the resulting column to Week):

 

Weeks = 
DISTINCT (
    UNION ( DISTINCT ( Table1[Creation Week] ), DISTINCT ( Table1[Closure Week] ) )
)

 

Measures:

 

Count Creation = 
CALCULATE (
    COUNT ( Table1[ID] ),
    TREATAS ( VALUES ( Weeks[Week] ), Table1[Creation Week] )
)
Count Closure = 
CALCULATE (
    COUNT ( Table1[ID] ),
    TREATAS ( VALUES ( Weeks[Week] ), Table1[Closure Week] )
)

 

Use Weeks[Week] in a visual:

 

DataInsights_0-1707229273622.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
DataInsights
Super User
Super User

@FrancaZ,

 

This solution requires a Weeks table consisting of each possible week. You can create this in Power Query or DAX. This table has no relationship with the data table. Here's a DAX calculated table (I renamed the resulting column to Week):

 

Weeks = 
DISTINCT (
    UNION ( DISTINCT ( Table1[Creation Week] ), DISTINCT ( Table1[Closure Week] ) )
)

 

Measures:

 

Count Creation = 
CALCULATE (
    COUNT ( Table1[ID] ),
    TREATAS ( VALUES ( Weeks[Week] ), Table1[Creation Week] )
)
Count Closure = 
CALCULATE (
    COUNT ( Table1[ID] ),
    TREATAS ( VALUES ( Weeks[Week] ), Table1[Closure Week] )
)

 

Use Weeks[Week] in a visual:

 

DataInsights_0-1707229273622.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.