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
Kyuss82
Regular Visitor

Strange behaviour of Power Bi vs Excel

Hi,

 

I'm a new user of Power Bi and i have a strange problem with a data filter applied to a measure that calculate a cumulative (monthly/year etc). My architecture is: SSAS in SQL Server 2012 sp4 and Power Bi as frontend.

 

In SSAS I've created a formula like this:

 

 

Cumulative Previous Year:=CALCULATE (
    SUM([TOTAL VOLUME]) ;
    FILTER (
       ALLSELECTED ('FACT TABLE');
        'CALENDAR TABLE'[YEAR]
            = (YEAR(  MAX('FACT TABLE'[DAY]))-1)&&'CALENDAR TABLE'[MONTH]<=(MONTH(MAX('FACT TABLE'[DAY])))&&'CALENDAR TABLE'[DAY]<=DAY(MAX('FACT TABLE'[DAY]))
    )
)

 

 

 This formula work as espected in Excel but give an empty result in Power Bi when for example a year is selected from a data filter.

 

What am I doing wrong?

 

Thanks

1 ACCEPTED SOLUTION

Ok found a solution for my problem

 

Using a formula like this:

Cumulative Previous Year:=CALCULATE (
    SUM([TOTAL VOLUME]) ;
    FILTER (
       ALL ('CALENDAR TABLE');
        'CALENDAR TABLE'[YEAR]
            = (YEAR(  MAX('FACT TABLE'[DAY]))-1)&&'CALENDAR TABLE'[MONTH]<=(MONTH(MAX('FACT TABLE'[DAY])))&&'CALENDAR TABLE'[DAY]<=DAY(MAX('FACT TABLE'[DAY]))
    );ALL('FACT TABLE'[DAY])
)

Now everything work as espected 😉

 

Regards

View solution in original post

5 REPLIES 5
Pragati11
Super User
Super User

Hi @Kyuss82 ,

 

Can you please put some screenshots from Power BI on what result this DAX expressions is giving? The expression looks right to me.

 

Thanks,

Pragati

 

 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Hi @Pragati11 ,

 

Thanks for your reply.

 

Here's the report in Power Bi without a filter

Power bi without filterPower bi without filter

 

Here's using the filter

report_with_filter.JPG

The same model using Excel

excel.JPG


Thanks

Hi @Kyuss82 ,

 

Try modifying your dax as follows:

 

Cumulative Previous Year:=CALCULATE (
SUM([TOTAL VOLUME]) ;
FILTER (
ALLSELECTED ('FACT TABLE');
'CALENDAR TABLE'[YEAR] = (YEAR( MAX('FACT TABLE'[DAY]))-1)&&'CALENDAR TABLE'[MONTH]<=(MONTH(MAX('FACT TABLE'[DAY]))) && ('CALENDAR TABLE'[DAY]<=DAY(MAX('FACT TABLE'[DAY])))
)
)

 

Just added 2 brackets in your DAX.

 

If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Thank you for your prompt reply @Pragati11 !

 

Unfortunately i've got the same result 😞

 

I'm starting to think that the problem is SSAS 2012 that maybe is too old to work correctly with Power BI...

Ok found a solution for my problem

 

Using a formula like this:

Cumulative Previous Year:=CALCULATE (
    SUM([TOTAL VOLUME]) ;
    FILTER (
       ALL ('CALENDAR TABLE');
        'CALENDAR TABLE'[YEAR]
            = (YEAR(  MAX('FACT TABLE'[DAY]))-1)&&'CALENDAR TABLE'[MONTH]<=(MONTH(MAX('FACT TABLE'[DAY])))&&'CALENDAR TABLE'[DAY]<=DAY(MAX('FACT TABLE'[DAY]))
    );ALL('FACT TABLE'[DAY])
)

Now everything work as espected 😉

 

Regards

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.