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
vips
Frequent Visitor

counts of status' based on dates

I am relatively new to Power BI.

 

I have a table of orders as shown here. I would like a *single* chart that represents bar graph of counts with date on X-axis.

  1. Total new orders = 6
  2. Orders by date 
    1. 4/1 = 3
    2. 4/2 = 2
    3. 4/3 = 1
  3. Warehouse process date
    1. 4/1 = 1
    2. 4/2 = 2
    3. 4/3 = 2
    4. 4/4 = 1
  4. Ship date
    1. 4/2 = 1
    2. 4/4 = 3
    3. 4/5 = 1
    4. 4/10 = 1

 

order IDorder datewarehouse process dateship date
14/14/14/2
24/14/24/4
34/14/34/4
44/24/24/10
54/24/34/4
64/34/44/5

 

What attribute should I use in the X-Axis and how do I get counts of each of the states on specific days?

 

Thanks much in advance!!

2 ACCEPTED SOLUTIONS
vivran22
Community Champion
Community Champion

Hello @vips ,

 

This you can achieve through making a separate calendar table:

 

dtCalendar = 
ADDCOLUMNS(
    CALENDARAUTO(),
    "Year", YEAR([Date]),
    "Month", EOMONTH([Date],-1)+1
)

 

then creating relationship between the Date of calendar table and all three dates from your fact table (one active and two inactive):

 

Relationship 2.PNGRelationship.PNG

 

Add three measures:

 

Count by Order Date = 
   COUNTROWS(dtTable)


Count by Process Date = 
CALCULATE(
    [Count by Order Date],
    USERELATIONSHIP(dtCalendar[Date],dtTable[warehouse process date])
)


Count by Ship Date = 
CALCULATE(
    [Count by Order Date],
    USERELATIONSHIP(dtCalendar[Date],dtTable[ship date])
)

 

Select Date from the calendar table and add these meausres in the visual:

 

Capture.PNG

 

You may find the solution pbix file here

 

Cheers!
Vivek

If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂

https://www.vivran.in/

Connect on LinkedIn

View solution in original post

amitchandak
Super User
Super User

@vips 

Create a common Date Calendar table. Join all three dates with it. There will one active and and two inactive relations. use userelation to activate joins.

example

Ordered = CALCULATE(COUNT(Table[Order Id ]),USERELATIONSHIP(Table[Order Date],'Date'[Date]) )

warehouse = CALCULATE(COUNT(Table[Order Id ]),USERELATIONSHIP(Table[warehouse process Date],'Date'[Date]) )
Ship = CALCULATE(COUNT(Table[Order Id ]),USERELATIONSHIP(Table[Ship Date],'Date'[Date]) )

Refer my blog how to use : https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@vips 

Create a common Date Calendar table. Join all three dates with it. There will one active and and two inactive relations. use userelation to activate joins.

example

Ordered = CALCULATE(COUNT(Table[Order Id ]),USERELATIONSHIP(Table[Order Date],'Date'[Date]) )

warehouse = CALCULATE(COUNT(Table[Order Id ]),USERELATIONSHIP(Table[warehouse process Date],'Date'[Date]) )
Ship = CALCULATE(COUNT(Table[Order Id ]),USERELATIONSHIP(Table[Ship Date],'Date'[Date]) )

Refer my blog how to use : https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Thanks!

vivran22
Community Champion
Community Champion

Hello @vips ,

 

This you can achieve through making a separate calendar table:

 

dtCalendar = 
ADDCOLUMNS(
    CALENDARAUTO(),
    "Year", YEAR([Date]),
    "Month", EOMONTH([Date],-1)+1
)

 

then creating relationship between the Date of calendar table and all three dates from your fact table (one active and two inactive):

 

Relationship 2.PNGRelationship.PNG

 

Add three measures:

 

Count by Order Date = 
   COUNTROWS(dtTable)


Count by Process Date = 
CALCULATE(
    [Count by Order Date],
    USERELATIONSHIP(dtCalendar[Date],dtTable[warehouse process date])
)


Count by Ship Date = 
CALCULATE(
    [Count by Order Date],
    USERELATIONSHIP(dtCalendar[Date],dtTable[ship date])
)

 

Select Date from the calendar table and add these meausres in the visual:

 

Capture.PNG

 

You may find the solution pbix file here

 

Cheers!
Vivek

If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂

https://www.vivran.in/

Connect on LinkedIn

vips
Frequent Visitor

Thanks!

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.