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
FatBlackCat30
Employee
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"))

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"))

worked perfectly thanks for the help

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.