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.
Hi
I've got multiple measures that are counting operations from the REST API based on dates.
- Operations total
- Operations in last 30 days
- Operations in last 90 days etc
Is there a more efficient way to do this without having 5 measures covering up to operations in the last 12 months?
Solved! Go to Solution.
Hi @analyst85 ,
Based on my testing, please try the following methods:
1.Create the simple table.
2.Create the new table.
3.Create the new measure to calculate operations for time periods.
Operations Count =
SWITCH(
TRUE(),
SELECTEDVALUE('Table Period'[Date Period]) = "Last 30 days", CALCULATE(SUM('Table'[Operations]), DATESINPERIOD('Table'[Date], LASTDATE('Table'[Date]), -30, DAY)),
SELECTEDVALUE('Table Period'[Date Period]) = "Last 90 days", CALCULATE(SUM('Table'[Operations]), DATESINPERIOD('Table'[Date], LASTDATE('Table'[Date]), -90, DAY)),
SELECTEDVALUE('Table Period'[Date Period]) = "Last 150 days", CALCULATE(SUM('Table'[Operations]), DATESINPERIOD('Table'[Date], LASTDATE('Table'[Date]), -150, DAY)),
SELECTEDVALUE('Table Period'[Date Period]) = "Last 270 days", CALCULATE(SUM('Table'[Operations]), DATESINPERIOD('Table'[Date], LASTDATE('Table'[Date]), -270, DAY)),
SELECTEDVALUE('Table Period'[Date Period]) = "Last 360 days", CALCULATE(SUM('Table'[Operations]), DATESINPERIOD('Table'[Date], LASTDATE('Table'[Date]), -360, DAY))
)
4.Drag the measure into the column visual.
5.The result is shown below.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You could create this DAX table and link it your date.
Calendar Ageing =
VAR _today_date = TODAY()
VAR _result =
UNION (
ADDCOLUMNS (CALENDAR ( _today_date - 30, _today_date), "Ageing Days", "Last 30 days", "Ageing Days Order", 1)
, ADDCOLUMNS (CALENDAR ( _today_date - 90, _today_date), "Ageing Days", "Last 90 days", "Ageing Days Order", 2)
, ADDCOLUMNS (CALENDAR ( _today_date - 150, _today_date), "Ageing Days", "Last 150 days", "Ageing Days Order", 3)
, ADDCOLUMNS (CALENDAR ( _today_date - 270, _today_date), "Ageing Days", "Last 270 days", "Ageing Days Order", 4)
, ADDCOLUMNS (CALENDAR ( _today_date - 360, _today_date), "Ageing Days", "Last 360 days", "Ageing Days Order", 5)
)
RETURN
_result
You could create this DAX table and link it your date.
Calendar Ageing =
VAR _today_date = TODAY()
VAR _result =
UNION (
ADDCOLUMNS (CALENDAR ( _today_date - 30, _today_date), "Ageing Days", "Last 30 days", "Ageing Days Order", 1)
, ADDCOLUMNS (CALENDAR ( _today_date - 90, _today_date), "Ageing Days", "Last 90 days", "Ageing Days Order", 2)
, ADDCOLUMNS (CALENDAR ( _today_date - 150, _today_date), "Ageing Days", "Last 150 days", "Ageing Days Order", 3)
, ADDCOLUMNS (CALENDAR ( _today_date - 270, _today_date), "Ageing Days", "Last 270 days", "Ageing Days Order", 4)
, ADDCOLUMNS (CALENDAR ( _today_date - 360, _today_date), "Ageing Days", "Last 360 days", "Ageing Days Order", 5)
)
RETURN
_result
Hi @analyst85 ,
Based on my testing, please try the following methods:
1.Create the simple table.
2.Create the new table.
3.Create the new measure to calculate operations for time periods.
Operations Count =
SWITCH(
TRUE(),
SELECTEDVALUE('Table Period'[Date Period]) = "Last 30 days", CALCULATE(SUM('Table'[Operations]), DATESINPERIOD('Table'[Date], LASTDATE('Table'[Date]), -30, DAY)),
SELECTEDVALUE('Table Period'[Date Period]) = "Last 90 days", CALCULATE(SUM('Table'[Operations]), DATESINPERIOD('Table'[Date], LASTDATE('Table'[Date]), -90, DAY)),
SELECTEDVALUE('Table Period'[Date Period]) = "Last 150 days", CALCULATE(SUM('Table'[Operations]), DATESINPERIOD('Table'[Date], LASTDATE('Table'[Date]), -150, DAY)),
SELECTEDVALUE('Table Period'[Date Period]) = "Last 270 days", CALCULATE(SUM('Table'[Operations]), DATESINPERIOD('Table'[Date], LASTDATE('Table'[Date]), -270, DAY)),
SELECTEDVALUE('Table Period'[Date Period]) = "Last 360 days", CALCULATE(SUM('Table'[Operations]), DATESINPERIOD('Table'[Date], LASTDATE('Table'[Date]), -360, DAY))
)
4.Drag the measure into the column visual.
5.The result is shown below.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
43 | |
26 | |
20 | |
14 | |
8 |
User | Count |
---|---|
75 | |
50 | |
47 | |
17 | |
17 |