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
PaulHallam
Helper II
Helper II

Producing a bell graph that works with slicers

Hi All,

 

I have the following table;

'DATA'

DateSensorNoOccupiedOccupiedbyDate
06 May 2019952600
06 May 2019952700
06 May 2019952800
06 May 2019952900
06 May 2019953000
06 May 2019953100
06 May 2019953200
07 May 2019952613
07 May 2019952703
07 May 2019952803
07 May 2019952903
07 May 2019953003
07 May 2019953113
07 May 2019953213
08 May 2019952613
08 May 2019952703
08 May 2019952803
08 May 2019952903
08 May 2019953003
08 May 2019953113
08 May 2019953213
09 May 2019952614
09 May 2019952714
09 May 2019952804
09 May 2019952904
09 May 2019953004
09 May 2019953114
09 May 2019953214
10 May 2019952613
10 May 2019952703
10 May 2019952803
10 May 2019952903
10 May 2019953003
10 May 2019953113
10 May 2019953213

 

I have added the Occupied Date column as;
OccupiedbyDate = calculate(sum(DATA[Occupied]),Filter(all('DATA'),DATA[Date]=earlier(data[date])))

This gives me the total of [Occupied] on a specific day and i can produce the bell graph as below;

 Annotation 2019-07-11 113253.jpg

This all works well BUT...this sums eveything in the 'DATA' table and i need to be able to filter sensor categories with a slicer.
I have another table as below;

'CATEGORY'

Sensor No.Category1Category2
9526ATop
9527ATop
9528ABottom
9529BMiddle
9530BMiddle
9531BMiddle
9532CMiddle

I need the bell graph to be able to be sliced by any of the categories i choose and by date range.
Can anyone help please?

 

 

 

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @PaulHallam 

 

I would recommend that you create a Dynamic Segmentation measure rather than a calculated column.

 

I have attached a sample PBIX doing this with your sample data.

The steps are:

  1. Create a "segment" table which at a minimum needs to contain the values to appear on the horizontal axis of the chart. In this case, it is all possible Occupancy values you need to display. In my sample file, I created a DAX calculated table that contains values from zero to the maximum sum of Occupied on any date.
    Occupancy = 
    SELECTCOLUMNS ( 
        GENERATESERIES ( 0, MAXX ( VALUES ( DATA[Date] ), CALCULATE ( SUM ( DATA[Occupied] ) ) ) ),
        "Occupancy", [Value]
    )
  2. Create a Date table - not strictly necessary but preferable when filtering by date. Create relationship between 'Date'[Date] and DATA[Date]
  3. Create the segmentation measure, that counts the number of occurrences of Date values with a particular Occupancy.
    Count of Date by Occupancy = 
    VAR DatesToInclude =
        SUMMARIZE ( DATA, 'Date'[Date] )
    RETURN
        SUMX ( 
            Occupancy,
            COUNTROWS ( 
                FILTER ( 
                    DatesToInclude,
                    CALCULATE ( SUM ( DATA[Occupied] ) ) = Occupancy[Occupancy]
                )
            )
        )
    This measure is a version of the Dynamic Segmentation measure described on DAX Patterns. In this case I restrict the dates to be included to just those appearing in DATA (subject to whatever filters are applied). I also use SUMX to handle multiple selection of Occupancy values.
  4. Now you can create a visual using Occupancy[Occupancy] on the axis and the above measure, which can be filtered as needed:image.png

     

Hopefully that helps. Please post back if needed 🙂

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi @PaulHallam 

 

I would recommend that you create a Dynamic Segmentation measure rather than a calculated column.

 

I have attached a sample PBIX doing this with your sample data.

The steps are:

  1. Create a "segment" table which at a minimum needs to contain the values to appear on the horizontal axis of the chart. In this case, it is all possible Occupancy values you need to display. In my sample file, I created a DAX calculated table that contains values from zero to the maximum sum of Occupied on any date.
    Occupancy = 
    SELECTCOLUMNS ( 
        GENERATESERIES ( 0, MAXX ( VALUES ( DATA[Date] ), CALCULATE ( SUM ( DATA[Occupied] ) ) ) ),
        "Occupancy", [Value]
    )
  2. Create a Date table - not strictly necessary but preferable when filtering by date. Create relationship between 'Date'[Date] and DATA[Date]
  3. Create the segmentation measure, that counts the number of occurrences of Date values with a particular Occupancy.
    Count of Date by Occupancy = 
    VAR DatesToInclude =
        SUMMARIZE ( DATA, 'Date'[Date] )
    RETURN
        SUMX ( 
            Occupancy,
            COUNTROWS ( 
                FILTER ( 
                    DatesToInclude,
                    CALCULATE ( SUM ( DATA[Occupied] ) ) = Occupancy[Occupancy]
                )
            )
        )
    This measure is a version of the Dynamic Segmentation measure described on DAX Patterns. In this case I restrict the dates to be included to just those appearing in DATA (subject to whatever filters are applied). I also use SUMX to handle multiple selection of Occupancy values.
  4. Now you can create a visual using Occupancy[Occupancy] on the axis and the above measure, which can be filtered as needed:image.png

     

Hopefully that helps. Please post back if needed 🙂

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Thanks Owen works a treat.

 

I'm not seeing what i thought i would from the millions of data points i have, but thats my 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.