Forum Discussion

laciodrom_80's avatar
laciodrom_80
Icon for Helper IV rankHelper IV
7 years ago
Solved

DAX expression, need suggestion

Hi all,

 

I have theese two tables with no relationship:

 

Table1                                            Table2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I have calculated Max and Min measures for the Value column and the measure IntervalGap which is Max-Min/15

 

 

Max = MAX(Table1[Value])

Min = MIN(Table1[Value])

IntervalGap= (Max-Min)/15

I would like to count how many values of Value column (Table1) belong to each of 15 intervals (from Min to Max with step IntervalGap) creating a measure or a calculated column to add in table2 where in the Index column are listed the fifteen intervals

 

Index column 1 represents the interval from Min to Min+IntervalGap

Index column 2 represents the interval from Min+IntervalGap to Min+2*IntervalGap

...

 

How can I achieve this goal with a DAX expression?

 

Thanks in advance for any clue!

  • Greg_Deckler's avatar
    Greg_Deckler
    7 years ago

    OK, here is what I am thinking in Table2:

     

    Column = 
    VAR __low = IF([Index]=1,[MinMeasure],[MinMeasure]+([Index]-1)*[IntervalGapMeasure])
    VAR __high= IF([Index]=15,[MaxMeasure],[MinMeasure]+[Index]*[IntervalGapMeasure])
    RETURN
    COUNTX(FILTER('Table1',[Value]>=__low && [Value]<=__high),[Scenario Number])

    May need tweaking but something along these lines I believe.

5 Replies

      • Greg_Deckler's avatar
        Greg_Deckler
        Icon for Community Champion rankCommunity Champion

        OK, here is what I am thinking in Table2:

         

        Column = 
        VAR __low = IF([Index]=1,[MinMeasure],[MinMeasure]+([Index]-1)*[IntervalGapMeasure])
        VAR __high= IF([Index]=15,[MaxMeasure],[MinMeasure]+[Index]*[IntervalGapMeasure])
        RETURN
        COUNTX(FILTER('Table1',[Value]>=__low && [Value]<=__high),[Scenario Number])

        May need tweaking but something along these lines I believe.

  • Anonymous's avatar
    Anonymous
    Not applicable

    I'm also a little bit lost reading your post.

    Can you provide sample data?