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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
googlogmob
Advocate II
Advocate II

Row level calculation over the dimention

I have to calculate measure DIFF = [PLAN]-[SUMM] over only [Type]  column for every value
and summ only values >0 

[PLAN] = SUM(tab[plan])
[SUMM] = SUM(tab[fact])



Screenshot_1.png

I tried use SUMMARIZECOLUMNS, but I got error "SummarizeColumns() and AddMissingItems() may not be used in this context"

DIFF = 
VAR tab = SUMMARIZECOLUMNS(crm[Type];"diff";[PLAN]-[SUMM]))
RETURN SUMX(tab;[diff])

and cant understand how to add checking 

[PLAN]-[SUMM] > 0

in this calculation 

Help please

1 ACCEPTED SOLUTION
DAX0110
Resolver V
Resolver V

Without having your source dataset to work with, I can only attempt a theoretical solution... have a try and see if this works:

 

Create a measure called "DIFF (PLAN-SUMM)" :

 

=VAR isInRow = HASONEVALUE( tab[Type] )

RETURN SUMX(

       VALUES( tab[Type] )

       ,  CALCULATE(

              VAR thePlan = SUM(tab[PLAN])

              VAR theSumm = SUM(tab[SUMM])

              VAR DIFF = thePlan - theSumm

              RETURN

                      IF ( DIFF >= 0, DIFF

                         , IF( isInRow, DIFF

                               , 0  )

                          )

              )

       )

 

This measure should work in both the grand total cell and in each row.

When it's in "row mode", all kinds of DIFF's will be displayed, but

when it's in grand total mode, only DIFF>=0 will be included.

 

View solution in original post

3 REPLIES 3
DAX0110
Resolver V
Resolver V

Without having your source dataset to work with, I can only attempt a theoretical solution... have a try and see if this works:

 

Create a measure called "DIFF (PLAN-SUMM)" :

 

=VAR isInRow = HASONEVALUE( tab[Type] )

RETURN SUMX(

       VALUES( tab[Type] )

       ,  CALCULATE(

              VAR thePlan = SUM(tab[PLAN])

              VAR theSumm = SUM(tab[SUMM])

              VAR DIFF = thePlan - theSumm

              RETURN

                      IF ( DIFF >= 0, DIFF

                         , IF( isInRow, DIFF

                               , 0  )

                          )

              )

       )

 

This measure should work in both the grand total cell and in each row.

When it's in "row mode", all kinds of DIFF's will be displayed, but

when it's in grand total mode, only DIFF>=0 will be included.

 

@DAX0110, it works as it should! 🙂
Thanks very much 

You're welcome!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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