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
vivekgupta84
Frequent Visitor

DAX Function to sum values by similar date

I have attached the data. I need a sum of values for each date. For example, 

1 Jan. 19:  (1200+275-929-30-464+198+884) = 1134

I have also a slicer in the report So I can filter the values by P1, P2, P3....

Why, I'm doing this? I want to calculate the number of days where the total value is greater than 0.

Screenshot (529).png

1 ACCEPTED SOLUTION

hi, @vivekgupta84 

 

no need of calculation

just drag your p-type to slicer and value column to card visual

when you select portfolio 1 then it show 1200

Dangar332_0-1710830893943.png

when you select portfolio 1 & 2 then it show 1475

Dangar332_1-1710830940785.png

 

View solution in original post

10 REPLIES 10
vivekgupta84
Frequent Visitor

Hi @lbendlin 

Thanks for the response. Here is the dataset - https://docs.google.com/spreadsheets/d/1ONfzT9f_2jA5daZfztP9L1HSgOBsqX8g/edit?usp=sharing&ouid=10595... 

I have attached a short dataset. The data has multiple years of data and around 10 P-type. The data has three columns P-type, Date and value. 

I need a sum of value by date. 

For example,  

Portfolio 1     1-Jan-19    1200
Portfolio 2    1 -Jan-19     275
Portfolio 3   1-Jan-19     -929


then the output for 1-Jan-19 is 546. 

I want this output to be filtered by P-type. So, when I click Portfolio1 in the slicer it will show 1200 only and when I click Portfolio 1 and 2 then it will show 1475. 

This is about the calculation.
------------------------------------------------------------------------------------------------------------------------------
I want to perform multiple calculations on this summarized output. Like monthly avg., daily avg., count of days where value is greater then 0, Highest and value in a day.  

hi, @vivekgupta84 

 

no need of calculation

just drag your p-type to slicer and value column to card visual

when you select portfolio 1 then it show 1200

Dangar332_0-1710830893943.png

when you select portfolio 1 & 2 then it show 1475

Dangar332_1-1710830940785.png

 

You don't need an explicit computation for that. Put the data in a matrix visual and Power BI will implicitly calculate it for you

lbendlin_0-1710778037338.png

 

Hi @lbendlin 
Thanks for the response. I know that Power BI will calculate these implicitly in the matrix visual. But I need a Card visual to show the data. 

For example, I have to calculate the count of dates where the value is greater than 0 "or" Maximum value for a date etc.

JamesFR06
Resolver IV
Resolver IV

Hi

 

Please try this measure

JamesFR06_0-1710709423749.png

CntDays =
var ActivDate=SELECTEDVALUE(CountDays[Date])
var base=CALCULATE(sum(CountDays[Value]),ALLSELECTED(CountDays[P Type]))
var result=if(base>0,1,0)
return
result
 
And at the end you put this measure on your panel with a value on 1
JamesFR06_1-1710709491937.png

 

Dangar332
Super User
Super User

hi, @vivekgupta84 

below measure might work

Measure = 
var a = SUMX(
    FILTER(ALL('Table'[date],'Table'[value],'Table'[p type]),
    'Table'[date]=MAX('Table'[date])
    ),
   'Table'[value])
return
COUNTX(FILTER(SUMMARIZE('Table','Table'[date],"sd",a),[sd]>0),1)

Hi @Dangar332 

It's not working. It is giving output 1229. I don't know what it is calculating. 

Is there any option to create a calculated column for this? I also want to filter it using a P-type column.


lbendlin
Super User
Super User

Sounds good. What have you tried and where are you stuck?  Did you try SUMMARIZECOLUMNS?

Hi @lbendlin

I have tried multiple DAX functions. Yes, I have tried to summarize columns but was unable to get the expected output.

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

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.