Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi 🙂
I'm trying to create the next calculation, to show the number of alerts per month.
The calculation of the alerts differs depending on the month:
If the date is smaller than 2023-02-01, display a calculation based on current month data.
If the date is greater than 2023-02-01, display a calculation based on the month before last month.
This is the calculation:
Total alerts = SWITCH( TRUE(),
RELATED('Ref_TimeTable_Alert'[DayDate] ) < DATE ( 2023, 2, 1 ), [measure1],
[measure2])
measure2 = CALCULATE([Total payments],'BLS'[Is_Alert] = "Yes", PREVIOUSMONTH(PREVIOUSMONTH('Ref_TimeTable_Alert'[DayDate])))
What Total alerts gives me, is only the first part of the statemnt - data before 2023-02-01.
This is what I get:
Year | Month | measure1 | measure2 | Total alerts |
2022 | November | 116 | 116 | |
2022 | December | 108 | 108 | |
2023 | January | 84 | 116 | 84 |
2023 | February | 51 | 108 | |
2023 | March | 64 | 84 | |
2023 | April | 39 | 51 |
And this is what I would like to get:
Year | Month | measure1 | measure2 | Total alerts |
2022 | November | 116 | 116 | |
2022 | December | 108 | 108 | |
2023 | January | 84 | 116 | 84 |
2023 | February | 51 | 108 | 108 |
2023 | March | 64 | 84 | 84 |
2023 | April | 39 | 51 | 51 |
Hi @Viksha
You can try the following measure
Total alerts =
IF (
EOMONTH ( SELECTEDVALUE ( 'Ref_TimeTable_Alert'[DayDate] ), 0 )
>= EOMONTH ( DATE ( 2023, 2, 1 ), 0 ),
[measure1],
[measure2]
)
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Ask questions in Eventhouse and KQL, Eventstream, and Reflex.
User | Count |
---|---|
84 | |
83 | |
64 | |
60 | |
55 |
User | Count |
---|---|
183 | |
111 | |
105 | |
77 | |
70 |