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

DAX Forecasting Issue

Hi There,

 

I have created a forecast by using the following DAX expression:

 

Actual Forecast = 
VAR
Revenue1YAGO= CALCULATE([Actual Revenue],DATEADD(Dates[Date],-1,YEAR))
VAR
Revenue2YAGO= CALCULATE([Actual Revenue],DATEADD(Dates[Date],-2,YEAR))
RETURN
DIVIDE(Revenue1YAGO + Revenue2YAGO ,2,0)

However when I try to seperate in a table with the following DAX:

 

Actual Type Forecast = CALCULATE([Actual Forecast],FILTER(VALUES('Types Only'[Types]),COUNTROWS(FILTER('Revenue Streams','Types Only'[Types]='Revenue Streams'[Revenue Groups]))))

It just shows me the same value for every type of revenue stream (See pic)

 

 

Capture.PNG

I've tried different things but just can't seem to get it to work.

 

Any help is appreciated.

 

Thanks

1 ACCEPTED SOLUTION

Hi everyone,

 

Apologies for the delay. Here are the steps I used:

 

1.Create a supporting table. All my revenue groups were listed in the first column and in the second column i contained what type that revenue group belonged to (See Pic)

 

Capture 1.JPG

 

2. Then i created the following measure based on the above supporting table:

 

 

Revenue Type = CALCULATE([Actual Revenue],FILTER(VALUES('Master Commissions'[Revenue Type]),COUNTROWS(FILTER('Revenue Streams','Master Commissions'[Revenue Type]='Revenue Streams'[Revenue Groups]))))

 

3. I then created another measure based on the revenue type measure:

 

Actual Type Forecast = 
VAR
    Revenue1YAGO= CALCULATE([Revenue Type],DATEADD(Dates[Date],-1,YEAR))
VAR
    Revenue2YAGO= CALCULATE([Revenue Type],DATEADD(Dates[Date],-2,YEAR))
RETURN
DIVIDE(Revenue1YAGO + Revenue2YAGO ,2,0)

4. I was then able to split the revenue into a matrix as i wanted (See screen shot)

 

Capture 2.JPG

 

Thank you

 

View solution in original post

5 REPLIES 5
mattbrice
Solution Sage
Solution Sage

One potential isue I see is the use of COUNTROWS in a FILTER function.  In Dax, 0 = FALSE and any other number = TRUE.  So if COUNTROWS returns any number, the currrently iterated value of 'Revenue Streams' will be included.  Is this what you intended?  Why not remove the COUNTROWS function?

Hi MAte,

 

Thanks for the response.

 

If I were to remove the countrows, how would i then be able to split it based on the row names?

Hi Mate,

 

I managed to figure it out finally after some tinkering.

 

Thanks

@lord_kaiser,

Glad to hear the issue is solved, you can share the correct DAX and accept your reply as answer to close this thread.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi everyone,

 

Apologies for the delay. Here are the steps I used:

 

1.Create a supporting table. All my revenue groups were listed in the first column and in the second column i contained what type that revenue group belonged to (See Pic)

 

Capture 1.JPG

 

2. Then i created the following measure based on the above supporting table:

 

 

Revenue Type = CALCULATE([Actual Revenue],FILTER(VALUES('Master Commissions'[Revenue Type]),COUNTROWS(FILTER('Revenue Streams','Master Commissions'[Revenue Type]='Revenue Streams'[Revenue Groups]))))

 

3. I then created another measure based on the revenue type measure:

 

Actual Type Forecast = 
VAR
    Revenue1YAGO= CALCULATE([Revenue Type],DATEADD(Dates[Date],-1,YEAR))
VAR
    Revenue2YAGO= CALCULATE([Revenue Type],DATEADD(Dates[Date],-2,YEAR))
RETURN
DIVIDE(Revenue1YAGO + Revenue2YAGO ,2,0)

4. I was then able to split the revenue into a matrix as i wanted (See screen shot)

 

Capture 2.JPG

 

Thank you

 

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.