Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
How to calculate days between 01/01/2021 and 31/01/2021 and the data is in the same column
Solved! Go to Solution.
Hi @Anonymous ,
Not very sure about your expected result. Maybe you would like to do some calculations in a specific range of dates. If so, you could take the following example as reference.
Sample data
Do calculations between 01/01/2021 and 31/01/2021 with measure, for instance, sum data between this range.
Create a Measure to the sum:
SumInRange = CALCULATE(SUM('Table'[Data]),FILTER('Table','Table'[Date]>=DATE(2021,1,1)&&'Table'[Date]<=DATE(2021,1,31)))
Then, the result will look like this.
Or count days in this range with the following measure.
CountDaysInRange = CALCULATE(COUNT('Table'[Data]),FILTER('Table','Table'[Date]>=DATE(2021,1,1)&&'Table'[Date]<=DATE(2021,1,31)))
Then, the visual looks like this.
So basically, you need use function like FILTER to filter data in the range you specified and then specify calculation expressions in the first parameter of CALCULATE.
Here are some links of corresponding dax functions that may help you.
FILTER function (DAX) - DAX | Microsoft Docs
CALCULATE function (DAX) - DAX | Microsoft Docs
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!
Best Regards,
Community Support Team _ Caiyun
Hi @Anonymous ,
Not very sure about your expected result. Maybe you would like to do some calculations in a specific range of dates. If so, you could take the following example as reference.
Sample data
Do calculations between 01/01/2021 and 31/01/2021 with measure, for instance, sum data between this range.
Create a Measure to the sum:
SumInRange = CALCULATE(SUM('Table'[Data]),FILTER('Table','Table'[Date]>=DATE(2021,1,1)&&'Table'[Date]<=DATE(2021,1,31)))
Then, the result will look like this.
Or count days in this range with the following measure.
CountDaysInRange = CALCULATE(COUNT('Table'[Data]),FILTER('Table','Table'[Date]>=DATE(2021,1,1)&&'Table'[Date]<=DATE(2021,1,31)))
Then, the visual looks like this.
So basically, you need use function like FILTER to filter data in the range you specified and then specify calculation expressions in the first parameter of CALCULATE.
Here are some links of corresponding dax functions that may help you.
FILTER function (DAX) - DAX | Microsoft Docs
CALCULATE function (DAX) - DAX | Microsoft Docs
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!
Best Regards,
Community Support Team _ Caiyun
Hi @Anonymous
please clarify further
User | Count |
---|---|
25 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
29 | |
13 | |
13 | |
10 | |
6 |