Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Aj24
Helper I
Helper I

Filtering Count for Chart by categories

Hi Genius Community!

Just wondering if anyone could provide some assistance on how to filter each ID by Rating where I can get the difference from initial date to last update month?

e.g

if its ID(A-yes) and rating = red then I would want the count to come back as:

date difference of: 3 month (taking initial as min and last update as max)

 

ID(A-yes) and rating = amber then I would want the count to come back as:

Data difference of: 1 month

 

This is a picture in the data and in the last column in bold – my desired result:

Aj24_0-1621256398903.png

My end goal is to create a bar chart with the x axis having months at rating (e.g 1-3 mths, 4-6 months etc) and the y axis having the count per ID. And the legend being the rating so it would be broken down into red and amber columns.

Table is called "Test".

 

my working script is:
Month_Difference = DATEDIFF(Test[Initial date].[Date], MAX(Test[Last update month].[Date], MONTH))+1

 

although i need the working script to also filter by rating for red and amber and ID

 

i will create x axis having the months at rating by: Months_Rating = SWITCH(Test[Months_Difference], 1, "1-3 months", 2, "1-3 months", 3, "1-3 months")

 

Thanks for all the help in advance! 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Aj24,

I'd like to suggest you create a calculated column on your fact table to group these records based on the offset of month diff ranges and use it as the axis of the chart.

Diff Group =
VAR offset = 3
VAR diff =
    DATEDIFF ( Test[Initial date], Test[Last update month], MONTH )
VAR rate =
    INT ( diff / offset )
RETURN
    IF (
        MOD ( diff, offset ) <> 0,
        rate * offset & " ~ " & ( rate + 1 ) * offset,
        ( rate - 1 ) * offset & " ~ " & rate * offset
    )

Regards,

Xiaoxin Sheng

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

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @Aj24,

I'd like to suggest you create a calculated column on your fact table to group these records based on the offset of month diff ranges and use it as the axis of the chart.

Diff Group =
VAR offset = 3
VAR diff =
    DATEDIFF ( Test[Initial date], Test[Last update month], MONTH )
VAR rate =
    INT ( diff / offset )
RETURN
    IF (
        MOD ( diff, offset ) <> 0,
        rate * offset & " ~ " & ( rate + 1 ) * offset,
        ( rate - 1 ) * offset & " ~ " & rate * offset
    )

Regards,

Xiaoxin Sheng

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.