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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PauSe
Frequent Visitor

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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