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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Dickkieee
New Member

How to modify my DAX to see weeks with no revenue.

I'm trying to visualize the total revenue per week, include the weeks with no revenue. For this purpose I tried to use 

 CALCULATE(
                    SUM('fct_test'[revenue]) ) 
 
Giving me the following result 
Dickkieee_0-1700591340834.png

But as you can see this visual is without the null weeks.

Therefore I tried it with the following DAX 

 

CALCULATE(
            SUM('fct_test'[revenue]),
            FILTER(
                ALL('DimDate'[Date]),
                'DimDate'[Date] <= MAX('DimDate'[Date])
 
The blue line is a target line (linear).
 
Dickkieee_1-1700591466548.png

 

How can I make a combination of both with the blue line and the first visualisation.

For the blue line I use the following dax

 

VAR b = [# CapaciteitHallen]
VAR a = 0.18
VAR pipestart = TODAY()
VAR maxdate = MAX(DimDate[Datum])
VAR x = datediff(pipestart,maxdate,week)
VAR line = b + a*b*x
RETURN IF(pipestart <= maxdate, line, BLANK())
 
Hope someone can help
1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @Dickkieee ,

To ensure that weeks with no revenue are included in your visual, you need to make sure that your date table (DimDate) has a continuous range of dates and that it is not filtered out by the relationships or the context of the report. Here's a revised version of your DAX measure that should help:

Total Revenue with Empty Weeks =
CALCULATE (
    SUM ( 'fct_test'[revenue] ),
    ALL ( 'DimDate' ),
    // This removes any filters from the DimDate table
    VALUES ( 'DimDate'[WeekNumber] ) // This ensures that you still group by week
)

 

Best regards,
Community Support Team_Binbin Yu
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

1 REPLY 1
v-binbinyu-msft
Community Support
Community Support

Hi @Dickkieee ,

To ensure that weeks with no revenue are included in your visual, you need to make sure that your date table (DimDate) has a continuous range of dates and that it is not filtered out by the relationships or the context of the report. Here's a revised version of your DAX measure that should help:

Total Revenue with Empty Weeks =
CALCULATE (
    SUM ( 'fct_test'[revenue] ),
    ALL ( 'DimDate' ),
    // This removes any filters from the DimDate table
    VALUES ( 'DimDate'[WeekNumber] ) // This ensures that you still group by week
)

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors