cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SaCvP125 Regular Visitor
Regular Visitor

Create a Clustered Column Chart using Two Summarize Measures

Hi guys,

 

I'm trying to create the following query using DAX:
WITH OPEN_DATA
                        AS
                            (
                            SELECT COUNT(DISTINCT [Ticket ID]) AS [Num_Open_Tickets]
                                        ,CAST([OPEN DATE] AS DATE) AS [Open Date]
                            FROM TableA
                            WHERE [OPEN DATE] >= DATEADD(DAY, -5,GETDATE())
                            GROUP BY CAST([OPEN DATE] AS DATE)
                            ),
            CLOSE_DATA
                        AS
                            (
                            SELECT COUNT(DISTINCT [Ticket ID]) AS [Num_Close_Tickets]
                                        ,CAST([CLOSE DATE] AS DATE) AS [Close Date]
                         FROM TableB
                         WHERE [OPEN DATE] >= DATEADD(DAY, -5,GETDATE())
                         GROUP BY CAST([CLOSE DATE] AS DATE)
                            )

SELECT CAST(COALESCE([Open Date],[Close Date]) AS DATE) AS [Date]
            ,ISNULL([Num_Open_Tickets],0) AS [Num_Open_Tickets]
            ,ISNULL([Num_Close_Tickets],0) AS [Num_Close_Tickets]
FROM OPEN_DATA
FULL OUTER JOIN CLOSE_DATA ON
    OPEN_DATA.[Open Date] = CLOSE_DATA.[Close Date]

 

For that I'm using the followinge measures to calculate the [Num_Open_Tickets] and [Num_Close_Tickets]:

Num_Open_Tickets= CALCULATE(
DISTINCTCOUNT(Tickets_Volumes[Ticket ID]);
ALLEXCEPT(Tickets_Volumes;Tickets_Volumes[OPEN DATE]))

 

Num_Close_Tickets = CALCULATE(
DISTINCTCOUNT(Tickets_Volumes[Ticket ID]);
ALLEXCEPT(Tickets_Volumes;Tickets_Volumes[CLOSE DATE]))

 

In powerBI I'm using a Clustered Column Chart with [Open Date ] in Axis and the Measures calculated in Values. But I'm getting the following chart:
Error1.PNG

 But I'm trying to get this:Error2.PNG

 

 

How Can I get this?

 

Many thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: Create a Clustered Column Chart using Two Summarize Measures

@SaCvP125,

 

Add a calendar table and use the following measures.

Num_Open_Tickets =
VAR d =
    MAX ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Tickets_Volumes[Ticket ID] ),
        Tickets_Volumes[OPEN DATE] = d
    )
Num_Close_Tickets =
VAR d =
    MAX ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Tickets_Volumes[Ticket ID] ),
        Tickets_Volumes[CLOSE DATE] = d
    )
Community Support Team _ Sam Zha
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
Highlighted
Community Support Team
Community Support Team

Re: Create a Clustered Column Chart using Two Summarize Measures

@SaCvP125,

 

Add a calendar table and use the following measures.

Num_Open_Tickets =
VAR d =
    MAX ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Tickets_Volumes[Ticket ID] ),
        Tickets_Volumes[OPEN DATE] = d
    )
Num_Close_Tickets =
VAR d =
    MAX ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Tickets_Volumes[Ticket ID] ),
        Tickets_Volumes[CLOSE DATE] = d
    )
Community Support Team _ Sam Zha
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

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 6 members 3,303 guests
Please welcome our newest community members: