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
Sreeragkv07
Frequent Visitor

what is the DAX measure for total cost from two dimension tables?

dax measure for getting total cost from fact table by comparing the dates columns from two diffrent dimension tables.

   i have a fact table with two  date ID fields and a cost column. 

startdatekey       enddatekey         cost
---------------     --------------      -------
1                                 a                   100
2                                 b                   100
3                                 c                    100
4                                 d                    100
And have Two different date table
startdatekey       Startdate        
---------------     --------------      
1                               1\1\1956 
2                                1\1\1980             
3                                1\1\1978               
4                                 1\1\1987     
 
enddatekey       enddate        
---------------     --------------      
1                               1\1\1954 
2                                1\1\1981            
3                                1\1\1970              
4                                 1\1\1983           
 
 
Total Cost=Sum of Cost when Start date<end date .There is no relationship between these tables.the Output should look like this 
startdate      end date     Total Cost
1\1\1980       1\1\1981     100
how can i create a measure to get Total cost with this condition.
 
5 REPLIES 5
lbendlin
Super User
Super User

Please correct the sample data as per your description.  US locale uses forward slash / ,  not backslash \

 

If your users provide end dates before start dates then you need to aask them for better data.

Actually its    forward slash.It was a Typing mistake

Hi @Sreeragkv07,

I think these operations should similar to common calculations, you need to lookup correspond date values based on keys and use them with datediff function to get the diff and calculate with cost field get total spends.
BTW, it seems like the source data is not correct, I suppose you need to do some data cleanup and transform to convert them to normal date values before calculate.
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Sreeragkv07
Frequent Visitor

Hi Ibendlin,

  -  Actually the userdata is given  same as mentioned.

   - end date key is in whole number  and the start date and end date in Date format.

  -   US Locale

 

 

 

    

lbendlin
Super User
Super User

Please correct your sample data

 

- some end dates are before the start dates

- end date key is numeric or alpha?

- which locale is this date format from?

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 Kudoed Authors