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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
TechR21
Helper V
Helper V

measure with automatic total number days of month

Hello,

 

Im using the following measure for a gauge to show the percentage of all runs of that month under 10 hours. This I do on a monthly base, so for januari i divide by 31.

 

Total % =
VAR less10 =
    CALCULATE ( COUNT ( 'Table'[Run] ), KEEPFILTERS ( 'Table'[Run] < 10 ) )
RETURN
    DIVIDE ( less10, 31 )

 

The gauge is on a page with different visuals, and Im using a filter to select the month that I want

 

How can I make this that it calculates the numbers of days in a month automatically, instead of putting a hard coded value in the measure?

 

 
 
 
 
1 ACCEPTED SOLUTION

Hi @TechR21 

 

Since you have a date filter, use the same date column in the variable:

VAR __DaysInMonth = DAY(EOMONTH(MAX('Date'[Date]),0))

vjingzhang_0-1675665743926.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@TechR21 You could do something like this:

VAR __DaysInMonth = DAY(EOMONTH(TODAY(),0))

Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I see its not the correct percentage when i look for the data of januari. Is this because the today part in the measure?

VAR __DaysInMonth = DAY(EOMONTH(TODAY(),0))

 

for januari i have 16 days of the 31 that are below 10 hours, so I get a percentage of 51.61, but the gauge shows

TechR21_0-1675436476269.png

 

On the filter I selected all days of januari so this should be the range of calculation. If I select all the days of feb at the end of this month, I want the measure to show the percentage based on the days in feb

 

VAR __DaysInMonth = DAY(EOMONTH(MONTH(-1),0)) this works:)

Hi @TechR21 

 

Since you have a date filter, use the same date column in the variable:

VAR __DaysInMonth = DAY(EOMONTH(MAX('Date'[Date]),0))

vjingzhang_0-1675665743926.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.