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
laciodrom_80
Helper IV
Helper IV

DAX expression, need suggestion

Hi all,

 

I have theese two tables with no relationship:

 

Table1                                            Table2

 

table1.pngtable2.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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!

Luca
1 ACCEPTED SOLUTION

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.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

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

Can you provide sample data?

 

Greg_Deckler
Super User
Super User

Not really following this. Sample data that can be copied and pasted always helps. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490. What is the relationship between those two tables?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler I've edited original post trying to be clearer.

 

No relationships between two tables

Luca

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.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

 

@Greg_Deckler

 

I was trying to make the report more configurable adding a filter by date column which is in Table1: changing date selection in the filter I'd like to have the updated values in the calculated column of Table2: how can I achieve this goal? I need a measure, right?

 

Thanks a lot

Luca

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.