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
jimpatel
Helper V
Helper V

Count of total dates per day

Hi,

 

Thanks a lot for looking at my post.

 

I would like to do the below logic in power bi, Any idea will be much appreciated.

 

I have "Item","Date1" and "Date2" column and i would like to get result in "Number of Date1" and "Number of Date 2" please. The logic is i wanted to count how many date1 and date 2 is falling in there respective date. I would like to create chart something like that as well. 

 

Any idea please?

jimpatel_0-1709717932002.png

 

 

Thanks a lot 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @jimpatel ,

 

Here are the steps you can follow:

1. Create calculated table – this column is the X-axis, which can contain all the de-emphasized data of Date1 and Date2.

Table 2 =
var _table=
DISTINCT('Table'[Date1])
var _table2=
DISTINCT('Table'[Date2])
var _table3=
UNION(_table,_table2)
return
CALENDAR(
    MINX(_table3,[Date1]),MAXX(_table3,[Date1]))

vyangliumsft_0-1709794140949.png

2. Create measure.

Number of Date1 =
COUNTX(
    FILTER(ALL('Table'),'Table'[Date1]=MAX('Table 2'[Date])),[Item])
Number of Date2 =
 COUNTX(
    FILTER(ALL('Table'),
    'Table'[Date2]=MAX('Table 2'[Date])),[Item])

3. Result:

vyangliumsft_1-1709794140959.png

 

 

Best Regards,

Liu Yang

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

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @jimpatel ,

 

Here are the steps you can follow:

1. Create calculated table – this column is the X-axis, which can contain all the de-emphasized data of Date1 and Date2.

Table 2 =
var _table=
DISTINCT('Table'[Date1])
var _table2=
DISTINCT('Table'[Date2])
var _table3=
UNION(_table,_table2)
return
CALENDAR(
    MINX(_table3,[Date1]),MAXX(_table3,[Date1]))

vyangliumsft_0-1709794140949.png

2. Create measure.

Number of Date1 =
COUNTX(
    FILTER(ALL('Table'),'Table'[Date1]=MAX('Table 2'[Date])),[Item])
Number of Date2 =
 COUNTX(
    FILTER(ALL('Table'),
    'Table'[Date2]=MAX('Table 2'[Date])),[Item])

3. Result:

vyangliumsft_1-1709794140959.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Sorry for reopening this topic. 

DAX formula works great and thanks a lot for that.

 

Is there any way we can use it in the same table instead of creating new table. I have several columns in "Table" which needs to be added in "Table2". That is i have created a "Table view" underneath the graph and it wont work by clicking the graph as both are seperate table.

 

Any idea please

thanks a lot

lbendlin
Super User
Super User

You would want to rearrange your data into a usable format, for example 

 

lbendlin_0-1709763796708.png

then the line chart is simple

lbendlin_1-1709763868906.png

 

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.