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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
FatBlackCat30
Microsoft Employee
Microsoft Employee

DAX Measure to sum based of relative date period

Hi all,

 

I am trying to create a DAX measure I can use in a card visual that will display the total sum (value column) for type column = customers for the last 2 days including today. 

 

there is what the data looks like: 

 

dateIDTypeValue
1/28/20211customer10
1/28/20211internal 15
1/28/20211users55
1/28/20211temp users669
1/28/20212customer69
1/28/20212internal 48
1/28/20212users86
1/28/20212temp users97
1/28/20213customer52
1/28/20213internal 34
1/28/20213users65
1/28/20213temp users888
1/29/20211customer463
1/29/20211internal 987
1/29/20211users525
1/29/20211temp users22
1/29/20212customer563
1/29/20212internal 1858
1/29/20212users11
1/29/20212temp users256
1/29/20213customer658
1/29/20213internal 478
1/29/20213users33
1/29/20213temp users25
1/28/20211customer154
1/28/20211internal 5454
1/28/20211users658
1/28/20211temp users578
1/28/20212customer596
1/28/20212internal 41654
1/28/20212users415
1/28/20212temp users552
1/28/20213customer6547
1/28/20213internal 552
1/28/20213users224
1/28/20213temp users4

 

thank you for the help

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@FatBlackCat30 , Based on what I got. Create a measure like

calculate(count(Table[ID]), filter(Table, Table[date] >=Today() -1 && Table[date] <=Today() && Table[Type] = "customer"))

 

or

 

calculate(distinctcount(Table[ID]), filter(Table, Table[date] >=Today() -1 && Table[date] <=Today() && Table[Type] = "customer"))

 

sum of value

calculate(count(Table[value]), filter(Table, Table[date] >=Today() -1 && Table[date] <=Today() && Table[Type] = "customer"))

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
amitchandak
Super User
Super User

@FatBlackCat30 , Based on what I got. Create a measure like

calculate(count(Table[ID]), filter(Table, Table[date] >=Today() -1 && Table[date] <=Today() && Table[Type] = "customer"))

 

or

 

calculate(distinctcount(Table[ID]), filter(Table, Table[date] >=Today() -1 && Table[date] <=Today() && Table[Type] = "customer"))

 

sum of value

calculate(count(Table[value]), filter(Table, Table[date] >=Today() -1 && Table[date] <=Today() && Table[Type] = "customer"))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

worked perfectly thanks for the help

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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