Forum Discussion
Compare in a bar graph
- 5 years ago
Hi JohnnyWind ,
You will need a separate calendar table in your data model, this is where you will get the [Month] field from for your chart axis. The easiest way to achieve this is to create a new table in the Data view and paste the following in the formula bar:
Calendar = ADDCOLUMNS( CALENDARAUTO(), "Month", FORMAT([Date], "mmm") )Once you have that, you can create relationships as follows:
1) Calendar[Date] (one) to YourTable[Created Date] (many) - ACTIVE relationship
2) Calendar[Date] (one) to YourTable[Closed Date] (many) - INACTIVE relationship
You would then create the following measures:
_noofCreated = DISTINCTCOUNT(aTable[Incident ID]) _noofClosed = CALCULATE( DISTINCTCOUNT(aTable[Incident ID]), USERELATIONSHIP(aTable[Closed date], Calendar[Date]) )Notice that the _noofClosed measure is different in that it uses CALCULATE and USERELATIONSHIP - this forces Power BI to use your inactive relationship between the calendar table and your table for that measure.
This give me the following output:
Pete
- 5 years ago
Hi, JohnnyWind
As mentioned by BA_Pete ,you can create a INACTIVE relationship.
I make a sample file.Hope it can help you ,If it doesn't meet your requirement, please share more details.
Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Rogletree,
The problem is that I have to month columns, one with open date and the other one with the closing date.
Best regards,
JohnnyWind you could try creating a lookup table that contains only the months, then create a relationship from that table to each of your incidents opened/incidents closed tables.
In power query, duplicate one of the tables. Then in your new table, remove all columns except for the months column. Then in that column, remove duplicate rows (sounds like there shouldn't be any duplicates anyways but just to be safe). Then close & apply.
Then go to "Model" view and in there you can create the relationships by dragging/dropping the fields on top of each other and Power BI will create the relationship. In the lookup table, click and hold the months field and drag it to the months field for the incidents created table. Then do the same thing with the other table.
Now you should be able to do the graph.