Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ClemFandango
Advocate II
Advocate II

How to add slicers onto a visual for a dataset that uses a separate date table

Hi all, I am hoping that one of you geniuses can help.  I have two tables:-

 

Table1 (133 rows of data)

DateProductCount
31/01/24  2
30/12/231
30/11/23 1
31/10/23  1

 

Date = end of month

ProductCount = A count of products where ‘Date’ from table 1 is found between (or equal to) the ‘Start’ & ‘End’ from table 2.

 

DAX from Table1 is as below:-

 

 

ProductCount =

COUNTROWS (
    FILTER (
        'Table2',
        [Date] >= 'Table2'[Start Date]
            && [Date] <= 'Table2'[End Date]
    )

)

 

 

 

Table2 (79, 278 rows of data)

Product     Start EndGroupSlicerCountrySliceTypeSlice3
Product 1    01/01/24   01/01/25   test      England     Main
Product 2   25/05/23  25/05/24    Test    WalesSubMain
Product 3    01/04/20   01/05/21   Test2     USA    Main

 

I want to create a chart that plots the result from ‘Table1’ (with Date as the x axis) alongside the slicers i.e Group, Country & Type from ‘Table2’. My end goal is to create a chart that calculates the number of products at the end of each month (as per table 1) with a few slicers.

 

Any idea how I can put table 1 into a visual, with the slicers from table 2? I suspect neither table is setup correctly to do this currently.

 

Any help will be eternally appreciated!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @ClemFandango 

I created the following sample data:

vjianpengmsft_0-1708942800900.png

vjianpengmsft_1-1708942819695.png

I use the following DAX to calculate the total at the end of each month:

 

Count = 
CALCULATE(COUNTROWS(FILTER(ALLSELECTED('Table'),[DATE]>='Table'[Start ]&&[DATE]<='Table'[End])))

 

I have created the following slicers:

vjianpengmsft_2-1708942927185.png

By setting the X-axis type to Categorical, the count at the end of each month is correctly displayed:

vjianpengmsft_3-1708943151268.png

vjianpengmsft_4-1708943187693.png

Dynamically calculate count through a type selected by the slicer:

vjianpengmsft_5-1708943267485.png

I have provided the PBIX file used this time below, I hope it can be helpful to you.

 

 

 

 

How to Get Your Question Answered Quickly

Best Regards

Jianpeng Li

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

10 REPLIES 10
Ashish_Mathur
Super User
Super User

Hi,

You do not need to create the Product count column in Table1.  Furthermore, a Calendar Table should have one entry per day.  You may refer to my solution of a similar problem in the attached file.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur this is amazing!

 

Do you have any idea how i could get this to provide totals against dates at end of month? (instead of Jan, Feb, Mar etc)?

 

Thanks agian,

 

CF

 

CF

You are welcome.  I cannot understand your requirement.  Apply my measures on your dataset, share the download link of the PBI file and clearly show what you want there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@ClemFandango , I am assuming table1 is date table with all dates , Keep it disconnected then you can have a measure like

 

Countrows(filter(Table2, Table2[Start Date]<= Max(Table1[Date]) && Table2[End Date]>= Max(Table1[Date]) ))

 

Power BI Dax Measure- Allocate data between Range: https://youtu.be/O653vwLTUzM

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi there @amitchandak 

 

Yes, you are correct. Table is the date table with just dates (all dates are for end of month).

 

Many thanks for the suggestion. When i try your measure, i get the error message 'The MAX function only accepts a column referance as an argument', which i dont really understand as they are column referances.

 

Any ideas where i am going wrong?

 

 

 

 

 

Hi @amitchandak 

 

I am unable to share my PBIX, but I will try to illustrate my query better.

 

My chart is as below

Screenshot.png

The chart currently calculates totals by each month, however I would like to calculate the totals by end of month.

 

I have a standard date table setup for each day 01/05/20, 02/05/20, 03/05/20 etc

ClemFandango_0-1708932039121.png

 

I have another table as below:-

Table1

ProductStartEndGroupSlicerCountrySlicerTypeSlice
Product 1   01/01/24   01/01/25   test   England   Main   
Product 2   25/05/23   05/05/24   test   Wales   Submain   
Product 3   01/04/20   01/05/21   test2   USA   Main   

 

This is the measure I am using...

productsatendofmonth = COUNTROWS(FILTER(Table1,[Start Date]<=[Selected max date]&&[End Date]>=[Selected min date]))

 

Your measure above correctly calculates the number of products each month, but I would like to calculate totals at the end of each month.

 

Is there any method to count the totals as of the end of each month, instead of just the whole month?

 

Any help greatly appreciated!

 

 

 

 

Anonymous
Not applicable

Hi, @ClemFandango 

I created the following sample data:

vjianpengmsft_0-1708942800900.png

vjianpengmsft_1-1708942819695.png

I use the following DAX to calculate the total at the end of each month:

 

Count = 
CALCULATE(COUNTROWS(FILTER(ALLSELECTED('Table'),[DATE]>='Table'[Start ]&&[DATE]<='Table'[End])))

 

I have created the following slicers:

vjianpengmsft_2-1708942927185.png

By setting the X-axis type to Categorical, the count at the end of each month is correctly displayed:

vjianpengmsft_3-1708943151268.png

vjianpengmsft_4-1708943187693.png

Dynamically calculate count through a type selected by the slicer:

vjianpengmsft_5-1708943267485.png

I have provided the PBIX file used this time below, I hope it can be helpful to you.

 

 

 

 

How to Get Your Question Answered Quickly

Best Regards

Jianpeng Li

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

 

 

 

Wow @Anonymous 

 

Thanks so much for the detailed explanation.

 

Have you any idea why I dont have the 'Catagorical' Type option?

ClemFandango_0-1708957704091.png

 

Oh I just opened the PBIX that you kindly sent, I think that you may have attached the wrong one.

 

Thanks so much again, It is really appreciated!

 

Anonymous
Not applicable

Hi, @ClemFandango 

I'm very sorry for my mistake. I have re-uploaded my PBIX file now, you can re-download it and view it. Regarding why you don't have the 'Catagorical' Type option, you can check whether your column is of numeric or date type. Please note that if the X-axis is string/boolean, the "Type" option will not show up. It should be numeric or date data type.

 

 

Hi @Anonymous @Ashish_Mathur @amitchandak 

 

I just wanted to say a huge thanks for all of your contributions. You all helped massivley to solve this for me.

 

Big thanks!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors