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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
fab196
Helper II
Helper II

COUNT VALUES FROM START OF MONTH USING DAX

HI 

 

i want to calculate total count 

here is my sql code 

 

declare @strdate date ='2021-09-21'

select CONVERT(date, cast( datefromparts(year(@strdate),month(@strdate),1) as datetime) , 120)

result of this query 

is 2021-9-01

 

so it is basically calculating total count from start of the month to till date as 

 

so iam using between operator in dax date column 

so how do i calculate the same in power bi 

suppose from date is 2021-09-21 and end date is 2021-09-21

so i want to calculate the data from 2021-09-01 to 21-09-2021 how to i do using dax

 

@parry2k  needed your support as always you are .

@amitcha

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@fab196 , if date is selected then you can use date tbale and time intelligence

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))

 

 

or

 

with today

MTD=
var _min = eomonth(today(),-1)+1
var _max = today()
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Table'),'Table'[Date] >= _min && 'Table'[Date] <=_max ) )

 

 

with date

 

MTD=

var _max =date(2021,09,01)
var _min = eomonth(_max ),-1)+1
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Table'),'Table'[Date] >= _min && 'Table'[Date] <=_max ) )

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

View solution in original post

2 REPLIES 2
Nepal101
Helper III
Helper III

In order to calculate the days between two dates, you can use Datediff.

Nepal101_0-1633615850314.png

hope this helps.

amitchandak
Super User
Super User

@fab196 , if date is selected then you can use date tbale and time intelligence

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))

 

 

or

 

with today

MTD=
var _min = eomonth(today(),-1)+1
var _max = today()
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Table'),'Table'[Date] >= _min && 'Table'[Date] <=_max ) )

 

 

with date

 

MTD=

var _max =date(2021,09,01)
var _min = eomonth(_max ),-1)+1
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Table'),'Table'[Date] >= _min && 'Table'[Date] <=_max ) )

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.