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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

How to divide only on the first day of the month

Hello everyone

I'm trying to calculate the DQ% for my company and that requires me to divide the total DQ (measure) running by just the first day of the month (not the whole month) for some reson no matter what I do is do all month. What am I doing wrong here? I also provided the DAX code for all fields.

Running Total DQ (Total DQ)
CALCULAR (
SUM ( 'Total collected'[total_collected] ),
FILTER(
ALLSELECTED('Total Collected'),
'Total Collected'[date] <-MAX('Total Collected'[date])
)
)
DQ general $ StartOfMonth ?
YES (
DATE(Year(TODAY()), MONTH(TODAY()), 1), [General DQ $],0
)
%Run: DIVIDE([Running DQ Total], Collections[Overall DQ $ StartOfMonth])
1 ACCEPTED SOLUTION
AlB
Super User
Super User

@Anonymous

Overall DQ $ StartOfMonth =
CALCULATE (
    [Overall DQ $],
    'Total Collected'[date] = DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), 1 )
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

5 REPLIES 5
AlB
Super User
Super User

@Anonymous 

It'd be better to operate with a date table. The previous version was too limited in that it operated on the current month only. Let's make a more general version:

 

Overall DQ $ StartOfMonth =
CALCULATE (
    [Overall DQ $],
    FILTER (
        ALL ( 'Total Collected'[date] ),
        'Total Collected'[date]
            = EOMONTH ( MAX ( 'Total Collected'[date] ), -1 ) + 1
    )
)

 

and then for the previous month, using the measure above:

 

Overall DQ $ StartOfMonth Previous =
CALCULATE (
    [Overall DQ $ StartOfMonth],
    FILTER (
        ALL ( 'Total Collected'[date] ),
        'Total Collected'[date] = EDATE ( MAX ( 'Total Collected'[date] ), -1 )
    )
)

 

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

AlB
Super User
Super User

@Anonymous

Overall DQ $ StartOfMonth =
CALCULATE (
    [Overall DQ $],
    'Total Collected'[date] = DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), 1 )
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Anonymous
Not applicable

That worked!!!!! Thank you so much for your help!!

 

 

 

Any idea how I can compare to last month on the line chart?

AlB
Super User
Super User

Hi @Anonymous 

Overall DQ $ StartOfMonth =
IF (
    MAX ( 'Total Collected'[date] )
        = DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), 1 ),
    [Overall DQ $],
    0
)

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

Anonymous
Not applicable

Thank you!! That worked slightly. But the percent is not going down for all of the days? 

 

I need it to divide by the first of the month for each day! I am so close!!

 

 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.