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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Dax based on Calendar Date

Hello,

I'm going to explain my problem.
I've got three different tables:
1) Table A : DATE, LABEL, CLIENT_ID, DISTINCTCOUNT(CLIENT_A)     (FILTERED TABLE BASED ON SQL QUERY)

2) Table B : START, END, LABEL, CLIENT_B  (TOTAL TABLE) 
3) Calendar = CALENDAR(MAX(TABLE_A(DATE)), MIN(TABLE_A(DATE))
I've to compute a measure like this :  % CLIENT = DISTINCTCOUNT(CLIENT_A) / DISTINTCOUNT(CLIENT_B) 
and insert this measure in a graph with month(DATE) on X-axis and % Client on Y-axis filtered by CLIENT of TABLE A.
So my denominator must follow the DATE on X-axis, for example if the month is JAN the START WOULD BE >= 1 JAN and END WOULD BE <= 31 JAN and so on for each month. 

This is my dax:

CountDistinctClientB=
VAR SelectedMonth = MAX(CALENDAR[DATE])
VAR StartMonth = DATE(YEAR(SelectedMonth), MONTH(SelectedMonth), 1)
VAR EndMonth = EOMONTH(SelectedMonth, 0)
VAR FilteredClient =
FILTER(
TABLE_B,
TABLE_B[START] >= StartMonth &&
TABLE_B[END] <= EndMonth
)
RETURN
CALCULATE(
COUNTROWS(SUMMARIZE(FilteredClient, TABLE_B[CLIENT_B])),
TABLE_B[LABEL] = SELECTEDVALUE(TABLE_A[LABEL])
)

Is there anyone who can help me please? 

I can't overcome this issue.

Thanks in advance 

 
 

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous ,

First month of year of selected date

CALCULATE(DISTINTCOUNT(TableB[CLIENT_B]) ,DATESMTD(dateadd('Date'[Date],(-1*month(Today())_ +1 ,MONTH)))

 

 

First Month This year Today =
var _min = eomonth(today(),-1*month(Today()))+1
var _max = eomonth(today(),-1*month(Today())+1)
return CALCULATE(DISTINTCOUNT(TableB[CLIENT_B]), FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

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

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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