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
atult
Advocate I
Advocate I

Need a Calculated Measure/Column

Hello Experts,
Below is the sample table for copying:

ChannelCompanyCategoryBrandRankValue
Channel1Company1Cat1Brand12100
Channel1Company2Cat1Brand2150
Channel2Company1Cat1Brand12200
Channel2Company2Cat1Brand21300

 

Image Representation:
SampleData.PNG

Requirement: Calculate the Difference column/measure. Basically it is Company1 Value - Company2 Value for the same Channel.

2 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

Column = if(Data[Company]="Company2",BLANK(),Data[Value]-CALCULATE(SUM(Data[Value]),FILTER(Data,Data[Channel]=EARLIER(Data[Channel])&&Data[Company]="Company2")))

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

Anand24
Super User
Super User

Hi @atult ,
Try the below calculated measure:

New Measure = 
MAXX(
    FILTER(
        ALL('Table'), 
        'Table'[COMPANY] <> "Company1" && 'Table'[Channel] in VALUES('Table'[Channel])
        ) , 
        'Table'[Value]
) 
- 
MAXX(
    FILTER(
        'Table', 
        'Table'[COMPANY] = "Company1" && 'Table'[Channel] in VALUES('Table'[Channel])
    ), 
    'Table'[Value]
)

 

PBI_SuperUser_Rank@1x.png  

Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!!

Proud To Be a Super User !!!
LinkedIn

View solution in original post

6 REPLIES 6
Anand24
Super User
Super User

Hi @atult ,
Try the below calculated measure:

New Measure = 
MAXX(
    FILTER(
        ALL('Table'), 
        'Table'[COMPANY] <> "Company1" && 'Table'[Channel] in VALUES('Table'[Channel])
        ) , 
        'Table'[Value]
) 
- 
MAXX(
    FILTER(
        'Table', 
        'Table'[COMPANY] = "Company1" && 'Table'[Channel] in VALUES('Table'[Channel])
    ), 
    'Table'[Value]
)

 

PBI_SuperUser_Rank@1x.png  

Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!!

Proud To Be a Super User !!!
LinkedIn

Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

Column = if(Data[Company]="Company2",BLANK(),Data[Value]-CALCULATE(SUM(Data[Value]),FILTER(Data,Data[Channel]=EARLIER(Data[Channel])&&Data[Company]="Company2")))

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
atult
Advocate I
Advocate I

@amitchandak@Greg_Deckler , @parry2k , @Ashish_Mathur 
Can you please look at this urgent requirement and help me?

@atult Try:

Column = 
  VAR __Channel = [Channel]
  VAR __Company = [Company]
  VAR __Category = [Category]
RETURN
  IF(
    __Company = "Company2",
    BLANK(),
    [Value] - MAXX(FILTER('Table',[Channel]=__Channel && __Company = "Company2" && __Category = [Category]),[Value])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler,
Thanks for the reply !
But this is giving me the exact same value in the new column.

@atult Sorry, slight syntax error:

Column = 
  VAR __Channel = [Channel]
  VAR __Company = [Company]
  VAR __Category = [Category]
RETURN
  IF(
    __Company = "Company2",
    BLANK(),
    [Value] - MAXX(FILTER('Table',[Channel]=__Channel && [Company]="Company2" && [Category]=__Category),[Value])
  )

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors