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
admin_xlsior
Post Prodigy
Post Prodigy

Help on DAX

Hi guys,

 

Need some help on my visualisation. I have this data which is an Item List, with its invoice date then a "age" time between that invoice data and my input date (lets call it As Of Date) :

ITEMINVOICEDATEAs of dateInvoice age
P-1000821/25/2016 0:001/4/2016 0:0021
P-1000831/25/2016 0:001/4/2016 0:0021
P-1000881/25/2016 0:001/4/2016 0:0021
P-1002492/8/2016 0:001/4/2016 0:0035
P-1002633/17/2016 0:001/4/2016 0:0073
P-1002643/17/2016 0:001/4/2016 0:0073
P-1002653/17/2016 0:001/4/2016 0:0073
P-1002663/17/2016 0:001/4/2016 0:0073
P-1002673/17/2016 0:001/4/2016 0:0073
P-1003593/14/2016 0:001/4/2016 0:00140
P-1003603/14/2016 0:001/4/2016 0:00140

 

I also have a Range Table like this :

NameFromTo
<=30 days030
31-90 days3190
> 90 days919999

 

Then for the clasification of the age, I create a measure like below :

Aging interval = CALCULATE(
                  VALUES('Range[Name]),
                  FILTER(
                     'Range',
                     'Items'[Invoice age] >= 'Range [FROM] &&
                     'Items'[Invoice age] < 'Range'[TO]
                                    )
)

 

If I create Table Visualization, it looks correct :

ITEMINVOICEDATEAs of dateInvoice ageAging interval
P-1000821/25/2016 0:001/4/2016 0:0021<= 30 days
P-1000831/25/2016 0:001/4/2016 0:0021<= 30 days
P-1000881/25/2016 0:001/4/2016 0:0021<= 30 days
P-1002492/8/2016 0:001/4/2016 0:003531 - 90 days
P-1002633/17/2016 0:001/4/2016 0:007331 - 90 days
P-1002643/17/2016 0:001/4/2016 0:007331 - 90 days
P-1002653/17/2016 0:001/4/2016 0:007331 - 90 days
P-1002663/17/2016 0:001/4/2016 0:007331 - 90 days
P-1002673/17/2016 0:001/4/2016 0:007331 - 90 days
P-1003593/14/2016 0:001/4/2016 0:0014091 - 150 days
P-1003603/14/2016 0:001/4/2016 0:0014091 - 150 days

 

Question is why I cannot put the Aging interval Measure to COLUMNS by using Matrix Visualization ?

 

I want to create something like this :

ITEM<= 30 days31 - 90 days91 - 150 days
P-1000821  
P-1000831  
P-1000881  
P-100249 1 
P-100263 1 
P-100264 1 
P-100265 1 
P-100266 1 
P-100267 1 
P-100359  1
P-100360  1

 

Can someone help or advice what should I do ?

 

Thanks,

 

 

1 ACCEPTED SOLUTION

Hi,

The AND() function takes 2 inputs.  Only when both inputs evaluate to TRUE will the AND() function also evaluate to TRUE. So if the Age of the invoice is >= min value and also <= max value, then it means that the Age of invoice falls between the min and ma values.  The AND() function will therefore evaluate to TRUE.  To convert TRUE to 1, one can multiply with 1.

Hope this clarifies.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

 

It works!!

I saw the measure, honestly I don't realy understand how it works ?

Measure = 1*(AND([Age of invoice]<=MAX('Ageing buckets'[To]),[Age of invoice]>=MIN('Ageing buckets'[From])))

 

Can you be so kind to explain a bit what's the logic in there? Sorry, but I'm really a beginner in DAX. I did some DAX material, but that one, is fantastic yet not easy for me to know what's going on.

Man Embarassed

 

Thanks,

 

Hi,

The AND() function takes 2 inputs.  Only when both inputs evaluate to TRUE will the AND() function also evaluate to TRUE. So if the Age of the invoice is >= min value and also <= max value, then it means that the Age of invoice falls between the min and ma values.  The AND() function will therefore evaluate to TRUE.  To convert TRUE to 1, one can multiply with 1.

Hope this clarifies.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi!

You can simplified this by creating a calculated column in your "items" table.

Create the calculated column with the next dax formula in your "items" table: 

INTERVAL = IF(ITEMS[Invoice age]>=0,IF(ITEMS[Invoice age]<=30,"<= 30 days",IF(ITEMS[Invoice age]<=90,"31 - 90 days","> 90 days")))
With this you can create the matrix you want:
 
interval.PNG
 

Hi, 

Sorry, I forgot to tell, I also need the range to be from a table. And what I know is I need to use CALCULATE to do that, however there is another stopper, I cannot use CALCULATE since I'm using Direct Query.

 

So that is the background story why I create a measure. (CALCULATE is not allowed for CalculatedColumn)

 

Thanks,

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.