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

filter Date to count for current date and last date of the same column on an inactive relationship

Hello,

I am stuck in create a dax calculation which counts number of entries based on single column. The facttable has 2 Date column - Date of Joined (DOJ) and Tentitive Date of Joining (TDOJ).  DOJ and TDOJ will have different dates.

 

DOJ is connected to calendar table to the date column and is active. There are slicers built using Calendar table columns like "Month" slicer. TDOJ has inactive relationship with Date column of the calendar table.

 

My ask is find count of TDOJ for a selected month  to future available months.  I am able to find the value for selected month by using userelationship function but unable to sum up the future months count.

 

Example:

NameDOJTDOJ
JohnJul-17Aug-17
KimAug-17Sep-17
TomSep-17Oct-17
JackOct-17Nov-17


As mentioned about DOJ is connected to Calendar table and slicer of Month from calendar table is used.

 

When we select Sep in the slicer the TDOJ count should be 3 and similar if Aug is selected the count should be 4

 

appreciate your help in figuring this out.

 

1 ACCEPTED SOLUTION

Hi @Sabarikumar7579,

 

My error since your sample data only add one value per month I used the variable 1 for each date your formula on the summarize table must be change to:

 

TDOJ_Table =
SUMMARIZE (
    ALL ( Joiner[TDOJ] ),
    Joiner[TDOJ],
    "Count", COUNT ( Joiner[TDOJ] )
)

Like this you are retuning the number of date repetions in your table so giving you the total counts that you need.

 

See the detail below and the PBIX file.

 

count_.png

 

I also made the order of the months so that it would be in alphabetic order 🙂

 

Any questions please tell me

 

regards,

MFelix

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

6 REPLIES 6
MFelix
Super User
Super User

Hi @,

 

Make a summarize table with the following code:

TDOJ_COUNT = SUMMARIZE(ALL(DOJ_Count[TDOJ]),DOJ_Count[TDOJ],"COUNT",1)

Then create the following measure:

Count_TDOJ =
VAR DATE_SELECTED =
    DATE ( YEAR ( MAX ( 'Calendar'[Date] ) ), MONTH ( MAX ( 'Calendar'[Date] ) ), 1 )
RETURN
    CALCULATE ( SUM ( 'Table'[COUNT] ), 'Table'[TDOJ] >= DATE_SELECTED )

I made the Date_Selected starting in the first day of the month since I from what i understood you want to count the current month plus the next months also assuming that you also choose the year in the slicers and not only the month.

 

The resul is something like this:

tDOJ.png

 

Regards,

MFelix

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi MFelix,

 

Thank you for your response. I tried your suggestion but for some reason its not giving the right output. link to download the PBX file. Please let me know where i am doing wrong.

 

Page 2 contains the actual number to showup.

 

Link to download PBIX file

Hi @Sabarikumar7579,

 

My error since your sample data only add one value per month I used the variable 1 for each date your formula on the summarize table must be change to:

 

TDOJ_Table =
SUMMARIZE (
    ALL ( Joiner[TDOJ] ),
    Joiner[TDOJ],
    "Count", COUNT ( Joiner[TDOJ] )
)

Like this you are retuning the number of date repetions in your table so giving you the total counts that you need.

 

See the detail below and the PBIX file.

 

count_.png

 

I also made the order of the months so that it would be in alphabetic order 🙂

 

Any questions please tell me

 

regards,

MFelix

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Thank you so much!

 

This work exactly perfect.

 

Regards
Sabari K

Hi @Sabarikumar7579,

 

download link not working.

 

 

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Sorry about it.

 

Here is the link: 

https://1drv.ms/u/s!AMht7QhPGrBBhzo

 

Regards

Sabari K

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.