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
Ali_Shakh
Helper II
Helper II

Converting monthly value into daily DAX

hi everyone!

 

please help with the following,

 

I'm trying to convert montly target value for sales into daily average with respect to number of days in a given month.

 

this is my data model

data_model.png

 tables are connected through calendar table, 
Actual table has data on daily level, but Plan table has data on monthly level

planned_vs_actual.png

 and I need to see it in the following format

Ali_Shakh_0-1678610684610.png

important thing to concider is days in each month

1 ACCEPTED SOLUTION

@Ali_Shakh 
Please try

Planned Sales Daily =
DIVIDE (
    [Planned Sales],
    COUNTROWS (
        CALCULATETABLE (
            VALUES ( 'Calendar'[Date] ),
            REMOVEFILTERS (),
            VALUES ( 'Calendar'[Year] ),
            VALUES ( 'Calendar'[Month] )
        )
    )
)

View solution in original post

7 REPLIES 7
tamerj1
Super User
Super User

Hi @Ali_Shakh 

why did you divide the march planned amount over 46.5 days? 331,962/46.5 = 7,139?

hi @tamerj1 ,
sorry, my bad I captured more days for march,
daily figure should be 10 708

@Ali_Shakh 
Please try

Planned Sales Daily =
DIVIDE (
    [Planned Sales],
    COUNTROWS (
        CALCULATETABLE (
            VALUES ( 'Calendar'[Date] ),
            REMOVEFILTERS (),
            VALUES ( 'Calendar'[Year] ),
            VALUES ( 'Calendar'[Month] )
        )
    )
)

@tamerj1 

still returns only one value 

Ali_Shakh_0-1678690304479.png

 

@Ali_Shakh 
This is a relationship cardinality issue.
You need to create the relationship between 'Date' and 'Planned' at month level not at day level. You can create a YearMonth column like FORMAT ( Planned[Date], "YYYYMM" ) in the Planned table and FORMAT ( 'Date'[Date], "YYYYMM" ) in the 'Date" table and connect both columns together Many-Many single direction.

@tamerj1 ,
you are a genius!

 

thanks, it works now, but how did you figured it out ? 

@Ali_Shakh 

It was very clear

1.png

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.

Top Solution Authors