cancel
Showing results for
Did you mean:
Regular Visitor

## if all

I  have a measure : "rupture" which is calculated (substraction) based on two other measures "Stock Week " and stock  Week-1.

I have good results when i'm in a weekly bucket, but when i'm in total, it gives me the result based on the total of "Stock Week " and "stock Week-1".

I would like to sum the "rupture "  of the weekly buckets when  i'm in All(week).

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team

## Re: if all

If you add some specify filter in measure, it will return the wrong result at total row. In my opinion, you can add a condition to filter the total row and add the specify calculation on it.

For example:

```Condition Calculate =
var currRowLabel=LASTNONBLANK('Table'[Date].[Month],'Table'[Date].[Month])
var currColumnLabel=MAX('Table'[Date].[Year])
return
if(COUNTROWS('Table')=COUNTROWS(ALL('Table')),
"all",//all
if(COUNTROWS('Table')=COUNTROWS(FILTER(ALL('Table'),[Date].[Month]=currRowLabel)),
"row",//row
if(COUNTROWS('Table')=COUNTROWS(FILTER(ALL('Table'),[Date].[Year]=currColumnLabel)),
"column",//column
SUM('Table'[Amount]))))```

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI
3 REPLIES 3
Highlighted
Regular Visitor

## Re: if all

Any help would be appreciated 🙂
Community Support Team

## Re: if all

If you add some specify filter in measure, it will return the wrong result at total row. In my opinion, you can add a condition to filter the total row and add the specify calculation on it.

For example:

```Condition Calculate =
var currRowLabel=LASTNONBLANK('Table'[Date].[Month],'Table'[Date].[Month])
var currColumnLabel=MAX('Table'[Date].[Year])
return
if(COUNTROWS('Table')=COUNTROWS(ALL('Table')),
"all",//all
if(COUNTROWS('Table')=COUNTROWS(FILTER(ALL('Table'),[Date].[Month]=currRowLabel)),
"row",//row
if(COUNTROWS('Table')=COUNTROWS(FILTER(ALL('Table'),[Date].[Year]=currColumnLabel)),
"column",//column
SUM('Table'[Amount]))))```

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI
Regular Visitor

## Re: if all

Many Thanks

Announcements

#### Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

#### Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

#### Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!