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
sivarajan21
Post Prodigy
Post Prodigy

Number of days in a month to find daily average

Hi,

 

I have below sample data set:

 

Missing Calendar Dates_1 table

DateDB Name - Points id
Apr 2,2022inse-1017
Mar 2,2022inse-1010
jun 2,2022northyorcc-65
feb 3,2022gmp-63

 

I need your help in creating a dax measure/calculated column to find number of days in a month. For example, the above table contains Apr 2,2022 in first row. April 2022 contains 30 days in that month.we need this 30 days to be returned in a measure or column. Similarly,next row contains Mar 2,2022 in 2nd row. March 2022 contains 31 days which the measure has to return.

 

The expected output could be as below, if it is a calculated column(feel free to use a measure(virtual) as well to return these days):

DateDB Name - Points idNo. of days
Apr 2,2022inse-101730
Mar 2,2022inse-101031
jun 2,2022northyorcc-6530
feb 3,2022gmp-6328

 

Please let me know if you need further info.

Please can you help me on this?

@Ahmedx @Arul @grantsamborn @lbendlin  @amitchandak @Ashish_Mathur @onurbmiguel_ @Greg_Deckler 

 

Thanks in advance.

1 ACCEPTED SOLUTION
VijayP
Super User
Super User

@sivarajan21 

You must have a datedimension to get a better result for this

CAlCULATE(COUNTROWS(DatesDim),ALL(DatesDim), VALUES(DateDim[MonthandYear])

So in your Date Table try to add monthandyear column as well!




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


View solution in original post

3 REPLIES 3
VijayP
Super User
Super User

@sivarajan21 

If this is solving your problem statement please Accept my answer as solution!




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Hi  ,

 

 

 

That works brilliantly!

 

You made this look so easy and thanks for this measure.

 

No of days =

CALCULATE (

COUNTROWS ( 'Calendar' ),

ALL ( 'Calendar' ),

VALUES ( 'Calendar'[Column] )

)

 

But I need your small help in solving the below which is the last bit we need to do. This involves the measures we had just created.

 

we have this sample dataset:

 

Target table

DBName-Point_idTarget typeValue TypeValue
northyorcc-10100Value_010
northyorcc-10100Value_0220
northyorcc-10100Value_0330.25
northyorcc-10100Value_04-132
northyorcc-10100Value_05-2
northyorcc-10100Value_060.29
northyorcc-10100Value_070.245
northyorcc-10100Value_08-199
northyorcc-10100Value_09-187
northyorcc-10100Value_10-11
northyorcc-10100Value_11-545
northyorcc-10100Value_121
inse-10170Value_011
inse-10170Value_0265

 

we need to find target unit.for each points id,we need to add numbers in  'Value' column. We should also make sure to add only the numbers that are having 'Target type' as 0 and not 1. After summation, we need to divide those by the measure 'No of days' created above.We need to create a calculated column for this target unit in below sample dataset.

 

Missing Dates calendar_1

DateDB Name - Points id
Apr 2,2022northyorcc-1010
Mar 2,2022inse-1017

 

The expected output would look something like below:

DateDB Name - Points idTarget units
Apr 2,2022northyorcc-1010-34.1405
Mar 2,2022inse-10172.096774

 

Target units column is derived from below formula:

target unit=Sum(value where target type 0)/No of days measure

value is taken from target table given above.

For example, northyorcc-1010 we got -34.1405 using formula as

target unit=-1024.215/30

-1024.215 is sum of value where target type is zero and 30 is no of days in april

 

Realtionship:

sivarajan21_0-1682514529364.png

 

Please let me know if you need further info.

Thanks in advance.

 

VijayP
Super User
Super User

@sivarajan21 

You must have a datedimension to get a better result for this

CAlCULATE(COUNTROWS(DatesDim),ALL(DatesDim), VALUES(DateDim[MonthandYear])

So in your Date Table try to add monthandyear column as well!




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


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.