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
PTIFANOU
Regular Visitor

Creating a chart with 2 dates to comapre entry and exit

Hi all, I am a complete newbe to PowerBI.

I have a table with 3 columns, the first one is "id file" each name is different, the second is the date of creation for each of this files,the third one is the date of cloture.

i'd like to make a bar chart that shows by month the number of files created (one bar) and the number of files finished (second bar)

thanks, and sorry for my english

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

@PTIFANOU OK:

  • Create a disconnected table for your months (no relationship) using an Enter Data query to just enter your month names in one column and the month number of the year (1...12) in the other column. Let's assume that you call this table "Months" and the columns are "Month" and "MonthSort" respectively
  • Set the Sort By column for the first column to be your second column
  • Create the following 2 DAX calculated columns in your table:
Creation Month = FORMAT([CreationDate],"mmmm")


Cloture Month = FORMAT([ClotureDaate],"mmmm")
  • Create the following 2 measures:
Documents Created = 
  VAR __Month = MAX('Months',[Month])
RETURN
  COUNTROWS(FILTER('Table',[Creation Month] = __Month))


Documents Cloture = 
  VAR __Month = MAX('Months',[Month])
RETURN
  COUNTROWS(FILTER('Table',[Cloture Month] = __Month))
  • Create a bar chart visual
  • Place Month column from your Months table into the X-axis field well
  • Place the two measures into the Y-axis field well

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Jihwan_Kim
Super User
Super User

Hi,

I suggest having a calendar table like below.

One active relationship and one inactive relationship.

And then use USERELATIONSHIP dax function when using inactive relationship.

 

Jihwan_Kim_1-1664724401186.png

 

 

Jihwan_Kim_0-1664724390766.png

 

Start count: =
COUNTROWS( Data )
 
End count =
CALCULATE( [Start count:],
    USERELATIONSHIP('Calendar'[Date], Data[EndDate])
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

I suggest having a calendar table like below.

One active relationship and one inactive relationship.

And then use USERELATIONSHIP dax function when using inactive relationship.

 

Jihwan_Kim_1-1664724401186.png

 

 

Jihwan_Kim_0-1664724390766.png

 

Start count: =
COUNTROWS( Data )
 
End count =
CALCULATE( [Start count:],
    USERELATIONSHIP('Calendar'[Date], Data[EndDate])
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Greg_Deckler
Super User
Super User

@PTIFANOU OK:

  • Create a disconnected table for your months (no relationship) using an Enter Data query to just enter your month names in one column and the month number of the year (1...12) in the other column. Let's assume that you call this table "Months" and the columns are "Month" and "MonthSort" respectively
  • Set the Sort By column for the first column to be your second column
  • Create the following 2 DAX calculated columns in your table:
Creation Month = FORMAT([CreationDate],"mmmm")


Cloture Month = FORMAT([ClotureDaate],"mmmm")
  • Create the following 2 measures:
Documents Created = 
  VAR __Month = MAX('Months',[Month])
RETURN
  COUNTROWS(FILTER('Table',[Creation Month] = __Month))


Documents Cloture = 
  VAR __Month = MAX('Months',[Month])
RETURN
  COUNTROWS(FILTER('Table',[Cloture Month] = __Month))
  • Create a bar chart visual
  • Place Month column from your Months table into the X-axis field well
  • Place the two measures into the Y-axis field well

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

thanks a lot both of yours solutions works perfectly

thanks fotr ur time and efforts

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.