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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
saivina2920
Post Prodigy
Post Prodigy

Data not fetching for TODAY DATE in DAX measure

I am creating measure. unfortunately, i have tested the below measure. 

vToday = TODAY()
vCalDate5 = [vToday] - 5
Emp Joined Date =
CALCULATE(DISTINCTCOUNT(EMP_TABLE[EMP_NUMBER]),FILTER(EMP_TABLE,
(EMP_TABLE[JOINED_DATE] >= [vCalDate5] && EMP_TABLE[JOINED_DATE] <= [vToday])

 

It will fetch only till yesterday records.

 

It will not fetch today rcords. what is the problem..?

1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@saivina2920 
You can not use duplicates as a calendar table. Create a new table. And create a 1 to many relationship between the new table[date] and the sheet1[date]).

 

Date Table = Distinct(Sheet1[Date])

 

 

Then replace the shee1[date] with DateTable[Date]

Measure = CALCULATE(DISTINCTCOUNT((EMP_TABLE[EMP_NUMBER]),EMP_STATUS = "Active", EMP_WORK = "REGULAR",DATESINPERIOD(DateTable[Date]),TODAY(),-5,DAY))  ==> Not working syntax error.

 


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
V-pazhen-msft
Community Support
Community Support

@saivina2920 
You can not use duplicates as a calendar table. Create a new table. And create a 1 to many relationship between the new table[date] and the sheet1[date]).

 

Date Table = Distinct(Sheet1[Date])

 

 

Then replace the shee1[date] with DateTable[Date]

Measure = CALCULATE(DISTINCTCOUNT((EMP_TABLE[EMP_NUMBER]),EMP_STATUS = "Active", EMP_WORK = "REGULAR",DATESINPERIOD(DateTable[Date]),TODAY(),-5,DAY))  ==> Not working syntax error.

 


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

HarishKM
Impactful Individual
Impactful Individual

@saivina2920 Hey,
You can use this one .

HarishKM_0-1617635302906.png
Kudos will be appriciated .

 

HarishKM
Impactful Individual
Impactful Individual

  1. @saivina2920 
  2. @saivina2920 Try this
  3.  
  4. Last 5 day = CALCULATE(Values(EMP_TABLE[EMP_NUMBER]),DATESINPERIOD(Sheet1[Date],TODAY(),-5,DAY))
    or 
    Last 5 day = CALCULATE(DISTINCTCOUNT((EMP_TABLE[EMP_NUMBER]),DATESINPERIOD(Sheet1[Date],TODAY(),-5,DAY)) 
    Thanks 

Thanks. 

i am using few more filter like EMP_STATUS = "Active" && EMP_WORK = "REGULAR"..

How we can apply the above filter if i use the below measure

CALCULATE(DISTINCTCOUNT((EMP_TABLE[EMP_NUMBER]),DATESINPERIOD(Sheet1[Date],TODAY(),-5,DAY)) 

 

Note : vToday is the main date function and used in many places..

 

Last 5 day with con =
Var last5 =DATESINPERIOD(Sheet1[Date],TODAY(),-5,DAY)
Return

CALCULATE(DISTINCTCOUNT((EMP_TABLE[EMP_NUMBER]),EMP_STATUS = "Active", EMP_WORK = "REGULAR",last5)

 

CALCULATE(DISTINCTCOUNT((EMP_TABLE[EMP_NUMBER]),EMP_STATUS = "Active", EMP_WORK = "REGULAR",DATESINPERIOD(Sheet1[Date],TODAY(),-5,DAY))  ==> Not working syntax error.

 

Error : A date column containing duplicate dates was specified in the call to function 'DATESINPERIOD'. This is not supported.

 

sorry. i don't undertand your measure.

can you correct us which i given in the post..?

if i give 

vToday = DATE(2021,4,6) ==> it will fetch till today. but. today date is "5". i am giveing "6" (2016,4,6)

if i give 

vToday = DATE(2021,4,5) ==> it will fetch till yesterday...how it is possible.???
 
ryan_mayu
Super User
Super User

@saivina2920 

i think your last condition

EMP_TABLE[JOINED_DATE] >= [vCalDate5] && EMP_TABLE[JOINED_DATE] <= [vCalDate5])

is the same as

(EMP_TABLE[JOINED_DATE] = [vCalDate5]

is there something wrong with this part?





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

Proud to be a Super User!




Yes. Sorry. i wrongly mentioned the measure. below is the one which i used.

vToday = TODAY()
vCalDate5 = [vToday] - 5
Emp Joined Date =
CALCULATE(DISTINCTCOUNT(EMP_TABLE[EMP_NUMBER]),FILTER(EMP_TABLE,
(EMP_TABLE[JOINED_DATE] >= [vCalDate5] && EMP_TABLE[JOINED_DATE] <= [vToday])

 

problem is here ==> EMP_TABLE[JOINED_DATE] <= [vToday])...????

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.