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
Chandramouli_BI
Helper III
Helper III

date_key count as a slicer

In my data there is Service column, EPK(Earning Per Km), date_key column in the format of (20230728.   2023-year, 07-month, 28-date) & data type of the column is whole number. Count of distinct date_key column is nothing but service operated days(SOD). I created a scatter plot with Avg EPK on X-axis, Count of distinct date_key(service operated days) & service in values. The scatter plot is of 16 grids(4*4=16) with 25th,50th,75th & 100th percentile llines for X-axis(avg EPK) & Y-axis(count of distinct date_key(SOD))

Now I wanted to create to slicers 

1. Avg EPK

2. Count of distinct date_key (service operated days)

Based on these two filters I want to filter/see services in the scatter plot.

 

But I am not able to create slicer for Count of distinct date_key column is nothing but service operated days(SOD).  It is coming as 1. But it should be in range from 1 to 91(since the data is for june,july& august months only). If I select a range a range of 1 to 70 the services run from 1 to 70 days(distinct date_key count) should come. But I am facing error

 

Someone Pls help me with this

 

SAMPLE FILE

https://docs.google.com/spreadsheets/d/1cZkc7pBvOHL9CrKCo1uUaJGBr05Ub8ge/edit?usp=sharing&ouid=10810... 

 

PBIX FILE

https://drive.google.com/file/d/1ydyOHZvhEhqP8Xqnh5c5GV7EgRwAmzWe/view?usp=sharing 

1 ACCEPTED SOLUTION

Hi @Chandramouli_BI ,

 

We can create a table.

Slicer = GENERATESERIES(1,DISTINCTCOUNT('agg_route'[date_key]),1)

Then we can create a measure.

count = MAX('Slicer'[Value])

vtangjiemsft_0-1702888288239.pngvtangjiemsft_1-1702888302712.png

Best Regards,

Neeko Tang

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-tangjie-msft
Community Support
Community Support

Hi @Chandramouli_BI ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.

vtangjiemsft_0-1702878812159.png

(2) We can create calculated columns.

Count of distinct date_key = CALCULATE(COUNT('Table'[date_key]),FILTER('Table','Table'[date_key]=EARLIER('Table'[date_key])))
Average EPK = AVERAGEX(FILTER('Table','Table'[date_key]=EARLIER('Table'[date_key])),[EPK]) 

(3) Then the result is as follows.

vtangjiemsft_1-1702878907321.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

Hi @Chandramouli_BI ,

 

We can create a table.

Slicer = GENERATESERIES(1,DISTINCTCOUNT('agg_route'[date_key]),1)

Then we can create a measure.

count = MAX('Slicer'[Value])

vtangjiemsft_0-1702888288239.pngvtangjiemsft_1-1702888302712.png

Best Regards,

Neeko Tang

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

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.