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
Anonymous
Not applicable

Consolidated Company Revenue Using DAX

Hi,

 

First of all, let me explain what type of data structure I'm dealing with. I work for a cross border logistics company. Therefore, the data model is constructed from two sources (2 companies) which can be separated by the Company Code (JWDA, JWDAC). I would like to show the consolidated revenue that came from both sides. There is a column named " Master Job No " which links the jobs of JWDA and JWDAC together.

 

 BI1.png

 

As you can see from the picture above, I would like to console the Total Revenue, Expense, and Gross Profit by using Master Job Number. For instance, The total revenue both rows of the Master Job No. JTH-2005-0050 must be $2052.35 ( which is 1700 + 352.35 ). Moreover, I would like to use the Shipper Name and Consignee Name as slicers. As I mentioned before, the data model was constructed with the data of two companies. So, the Shipper Name and Consignee Name of both sides are not the same. To avoid the confusion, I also would like to filter the slicers of shipper and consignee names to be from only JWDA as shown in the picture below.

BI2.PNG

This is what I have tried

 

 

End-to-End Revenue = 
IF(HASONEVALUE(Shipment[Master Job No]), 
CALCULATE( [Total Revenue], 
    ALL(Shipment[Shipper Name]),  
    ALL('Company Master'[Company ID])), 

CALCULATE(
    SUMX(VALUES(Shipment[Master Job No]),
        CALCULATE( [Total Revenue], 
            ALL(Shipment[Shipper Name]),  
            ALL('Company Master'[Company ID])))))

 

 

 

And the output is shown in the picture below.  But when I use the slicers it seems not correct.

BI3.png 

For your further information, I have attached the dummy file to this link.

https://drive.google.com/file/d/1i1rsWKmzwcdsUK375BYrxN-fqk-iQzLg/view?usp=sharing 

 

Thank you in advance,

Paniti

 

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @Anonymous ,

 

I would create two new calculated columns shipper (JDWA) and consignee (JDWA).

The DAX for the calculated column shipper (JDWA) would be similar to this:

shipper (JDWA) = 
if('tablename'[Company Code] = "JDWA"
,'tablename'[Shipper name]
,var __MasterJobNo = 'tablename'[Master Job No]
var shipperJDWA = LOOKUPVALUE(
	'tablename'[Shipper Name] ,
	'tablename'[Company Code] , "JDWA"
	'tablename'[Master Job No] , __MasterJobNo
)
return
if(ISBLANK(shipperJDWA), 'tablename'[Shipper Name] , __MasterJobNo)

Then you can use both new columns as slicer, using the value from the JDWA row.

 

Hopefully, this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Hey @Anonymous ,

 

I would create two new calculated columns shipper (JDWA) and consignee (JDWA).

The DAX for the calculated column shipper (JDWA) would be similar to this:

shipper (JDWA) = 
if('tablename'[Company Code] = "JDWA"
,'tablename'[Shipper name]
,var __MasterJobNo = 'tablename'[Master Job No]
var shipperJDWA = LOOKUPVALUE(
	'tablename'[Shipper Name] ,
	'tablename'[Company Code] , "JDWA"
	'tablename'[Master Job No] , __MasterJobNo
)
return
if(ISBLANK(shipperJDWA), 'tablename'[Shipper Name] , __MasterJobNo)

Then you can use both new columns as slicer, using the value from the JDWA row.

 

Hopefully, this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Dear @TomMartens 

 

Thank you for your support. Your suggestion got me to the right answer.

 

Thank you and best regards,

Paniti

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.