Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
I have two dataset importted in power bi
Dataset1 keeps the appliable loaded amount for evreyday use and this has two dates start and end date which shows from when to when this amount is aplicable
DataSet1
| Allotted date | Start Date | End Date | Loaded_Amount | UserId |
| 3/9/2024 | 3/9/2024 | 6/26/2024 | 65853 | 12 |
| 2/28/2024 | 2/28/2024 | 3/10/2024 | 99853 | 12 |
| 1/9/2024 | 1/09/2024 | 2/26/2024 | 77618 | 12 |
| 1/5/2024 | 1/5/2024 | 1/27/2024 | 50972 | 12 |
| 12/28/2023 | 12/28/2023 | 1/27/2024 | 67801 | 12 |
Dataset2 has evreyday usage from the customer interms of total_ordered_amount, this has enetry for every day
| UserId | date | order amount |
| 12 | 1/1/2024 | 100 |
| 12 | 1/2/2024 | 100 |
| 12 | 1/3/2024 | 150 |
| 12 | 1/4/2024 | 170 |
| 12 | 1/5/2024 | 1000 |
| 12 | 1/6/2024 | 1050 |
| 12 | 1/7/2024 | 1300 |
| 12 | 1/8/2024 | 1040 |
| 12 | 1/9/2024 | 1600 |
| 12 | 1/10/2024 | 1900 |
Now I need to derive the measure which will show daywise loaded amount usage = loaded_amount - total_ordered_amount for each userID
Here how to get the loaded amount for given date, becuse my dataset1 does not keep daywise amount, it has start_date and end_date
For example ,
case 1: for 1/6/2024 I need to get loaded amount as 50972
Case 2: for 1/10/2024 I need to get as 77618 though the enddate is 1/27/2024 , there is new amount loaded on 1/9/2024 so need to get as 77618
Is there a some DAX function which can help to calclaute diference of order amount from Dataset1 and Loaded_Amount from Dataset2 based on the lookup with consdiering the above cases
Solved! Go to Solution.
Hi,
I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
Order amount measure: =
SUM( 'Order'[order amount] )
Load amount measure: =
VAR _currentdate =
MAX ( 'Calendar'[Date] )
VAR _loadtable =
FILTER (
Load,
Load[Allotted date] <= _currentdate
&& Load[Start Date] <= _currentdate
&& Load[End Date] >= _currentdate
)
VAR _lastallotteddate =
MAXX ( _loadtable, Load[Allotted date] )
VAR _laststartdate =
MAXX ( _loadtable, Load[Start Date] )
RETURN
SUMX (
FILTER (
_loadtable,
Load[Allotted date] = _lastallotteddate
&& Load[Start Date] = _laststartdate
),
Load[Loaded_Amount]
)
Hi,
I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
Order amount measure: =
SUM( 'Order'[order amount] )
Load amount measure: =
VAR _currentdate =
MAX ( 'Calendar'[Date] )
VAR _loadtable =
FILTER (
Load,
Load[Allotted date] <= _currentdate
&& Load[Start Date] <= _currentdate
&& Load[End Date] >= _currentdate
)
VAR _lastallotteddate =
MAXX ( _loadtable, Load[Allotted date] )
VAR _laststartdate =
MAXX ( _loadtable, Load[Start Date] )
RETURN
SUMX (
FILTER (
_loadtable,
Load[Allotted date] = _lastallotteddate
&& Load[Start Date] = _laststartdate
),
Load[Loaded_Amount]
)
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 3 | |
| 2 | |
| 1 |
| User | Count |
|---|---|
| 21 | |
| 14 | |
| 9 | |
| 5 | |
| 5 |