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
vissvess
Helper V
Helper V

Count number of change over of a field over a period of time

Hi all,

 

 I need a measure that counts the changes in a particular period.

 

For example, in a production line, say the mapping of product occurs and timestamp is being captured for the process.

 

In an hour window, say first 10 units belong to Family A followed by 15 units belong to family B, 5 units of family A, 3 units of family C and so on.

 

I need a measure that provides me thee number of changeover occured on top of filter applied on date,hour and conveyor selection.

 

I need the community folks help to get me an idea on how to approach the requirement and the schema or syntax of the dax required.!!!!

 

Kindly Help me in this regard

 

Vissvess 

7 REPLIES 7
kentyler
Solution Sage
Solution Sage

so your "fact" table might look like this

 

Production DateProduction HourProduct FamilyQuantity ProducedConveyor
1/1/20191a3323
1/1/20193b4612
1/1/20194c5744
1/1/20195d4522
1/1/20197e3444

It would probably be useful to have an "Hours" table with entries 1 thru 24 that could be in a relationship with your Hour column...might help to handle cases where there was no production in some hours.you probably want to add a "calendar table" as a dimension for your dates (you can find lots of information about how to create a calendar table online)

You probably would also want a "product family" table with a column you could link to the product family column, that might contain other information about product families you would want to group count or slice by. You might also find a "conveyer" dimension table useful. This will give you a star schema, with the fact table having a many to one relationship with all of your dimension tables.

if you place data from a table like this on a matrix it will probably be easy to have rows for date/hour/conveyor and then have it count the number of families. You probably would not have to write dax to produce a report like that.





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Hi @kentyler , 

 

Thanks for the effort.

 

Consider the data as follows.

 

Production DateProduction HourProduct FamilyTimeConveyor
1/1/20191a01:10:1023
1/1/20191b01:10:2523
1/1/20191a01:10:4223
1/1/20191a01:11:0123
1/1/20191b01:12:1023

and so on..

So, the date is same and the conveyor is same. 

 

The product output time and itz family is captured. Hour will be hour value of the timestamp.

 

Now I consider changeover as 1(a-->b), 2(b-->a) 3(a-->b) again and so on.. till the hour (or day) ends.

 

Changeover is from any state to anystate despite historical presence which is different from number of family in any production hour. Hope I explained for your understanding.

 

Sorry for not sharing any datamodel or pbix file as they are onto organizational privacy.

 

Kindly do the needful.

Thanks

So does each new record represent one of the changes you are trying to count ? If so then your count might just be a COUNTROWS() over the period, minus 1 to not count the start row.





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


NO... @kentyler ,

 

Count rows would not help. If the earlier entry is same as the current one.. No counting to happen.

 

'X' should be one up if there is difference between earlier and current..

 

Anyone kindly help me to sort this out.

 

@HotChilli , @Stachu , @Anonymous , @Greg_Deckler , @Zubair_Muhammad ....

 

Thanks in advance.

Hi,

 

For the above my query on number of changeover in the specified period, an Idea sprung up.

 

I request the community folks to get me out of this with this idea....

 

I need a calculated column that holds the value of earlier family and concatenate with current entry family.

 

IF both (current and earlier families) are same, It should return blank else the concatenated family name should be there.

 

Then I shall count the number of entries for me to get the changeover.

 

Kindly help @Nathaniel_C  @Mariusz  @Anonymous  @sturlaws  @Anonymous  @Zubair_Muhammad  @HotChilli  @Stachu @parry2k @LAndes 

 

Thanks in advance.

@vissvess 

 

Try this MEASURE

Put Conveyor and this MEASURE in a table visual

 

Measure =
SUMX (
    ADDCOLUMNS (
        'TableName',
        "myCount",
        VAR PreviousFamily =
            MINX (
                TOPN (
                    1,
                    FILTER ( 'TableName', [Time] < EARLIER ( 'TableName'[Time] ) ),
                    [Time], DESC
                ),
                [Product Family]
            )
        RETURN
            IF (
                OR ( ISBLANK ( PreviousFamily ), PreviousFamily = [Product Family] ),
                0,
                1
            )
    ),
    [myCount]
)

Regards
Zubair

Please try my custom visuals

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.

Top Solution Authors