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
Fusion_Tomo
Advocate I
Advocate I

Count instances only if categorised the same for previous 3 months

Hey guys,

I have the following fact table that records mobile phone billings as at the last day of each month:

Fusion_Tomo_2-1666232531369.png

The table is connected to a Calendar table and a Mobile Service dim table that contains the details for every mobile service (number, plan type etc,). Each month the individual mobile services are categorised according to their data usage as either being Zero/Under, Excessive, or Nominal as per the Data Use Category column.

I would like to recreate the below stacked bar chart that counts the number of mobile services in the Zero/Under & Excessive categories for the past three months. By this I mean:

  • A mobile service will be counted in the Excessive category only if it has been categorised as Excessive for the given month AND the previous 2 months
  • A mobile service will be counted in the Zero/Under category only if it has been categorised as Zero/Under for the given month AND the previous 2 months
  • The remainder shall be counted as Nominal no matter what their classification for the given and previous 2 months is.

Fusion_Tomo_1-1666229610174.png

I am going to put this chart in a dashboard that is filterd by a single selection of MM-YY.

To summarise: a mobile service has to be classified as either Zero/Under or Excessive for three consectutive months up to and including the selected month or else it is counted as Nominal.

Any help constructing the neccessary measure(s) to accomplish this would be much appreciated.

Regards,

Steven.

 

 

2 REPLIES 2
Shaurya
Memorable Member
Memorable Member

Hi @Fusion_Tomo,

 

You can use the following DAX Formula:

 

Category = IF(CALCULATE(DISTINCTCOUNT('Table'[Data Usage Category],FILTER(DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-3,MONTH)))=1
&& 'Table'[Data Usage Category]<>"Nominal",
MAX('Table'[Data Usage Category]),
"Nominal")

 

Works for you? Mark this post as a solution if it does!
Consider taking a look at my blog: How to Export Telemetry Data from Azure IoT Central into Power BI

Thank you for taking the time to respond but that doesn't work - Power BI will not allow me to enter the 'Table'[Data Usage Category]<>"Nominal" condition and I'm not sure the logic of the formula is suited to the problem.

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.