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
PauSe
Helper I
Helper I

When data for a calendar day is missing ... Power Query or DAX solution?

I have a table that should provide a row per calendar day and is refreshed several times a day. The data is the current stock level of a warehouse. Based on the data, two measures make a simple 7-day simulation of expected warehouse space. The calculation is cumulative and quite straightforward and the main measure is below. 

 

Occasionally there isn't a row for "NetOfDeliveryCollection" on a calendar day so the simulation goes awry. I think I just need to add a value of zero for that missing day but my quesiton is how? Should I create a fake row in the dataload script or just add an IF condition in the DAX.

 

Either method, I don't know how to do this! 

 

Measure = SUM(DailyBalances[CurrBalance])
+ CALCULATE(
SUM(Delivery[NetOfDeliveryCollection])
, FILTER(
ALLSELECTED(Delivery)
,Delivery[DelDate] <= MAX(Delivery[DelDate])
)
)

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @PauSe 

 

You can add IF conditions to the DAX. This is shown below.

Measure =
VAR N1 =
    SUM ( DailyBalances[CurrBalance] )
        + CALCULATE (
            SUM ( Delivery[NetOfDeliveryCollection] ),
            FILTER (
                ALLSELECTED ( Delivery ),
                Delivery[DelDate] <= MAX ( Delivery[DelDate] )
            )
        )
VAR N2 =
    SUM ( DailyBalances[CurrBalance] ) + 0
RETURN
    IF ( SELECTEDVALUE ( Delivery[NetOfDeliveryCollection] ) = BLANK (), N2, N1 )

 Please try this formula, does this match your desired result?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @PauSe 

 

You can add IF conditions to the DAX. This is shown below.

Measure =
VAR N1 =
    SUM ( DailyBalances[CurrBalance] )
        + CALCULATE (
            SUM ( Delivery[NetOfDeliveryCollection] ),
            FILTER (
                ALLSELECTED ( Delivery ),
                Delivery[DelDate] <= MAX ( Delivery[DelDate] )
            )
        )
VAR N2 =
    SUM ( DailyBalances[CurrBalance] ) + 0
RETURN
    IF ( SELECTEDVALUE ( Delivery[NetOfDeliveryCollection] ) = BLANK (), N2, N1 )

 Please try this formula, does this match your desired result?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks, this answered my question of how to add an IF into a DAX. For the record, your formula  didnt solve my problem but you have answered my question. 

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.