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
msatterwhite
Frequent Visitor

Using DAX Measure for Categories against SSAS Direct Connection

I have seen several posts about creating Categories using DAX but I'm having difficulty using any of them against my SSAS connection.

I'm trying to create aging buckets and do a count of distinct values falling into each bucket.  So far, I've been able to create my aging buckets and view them in a table that contains each value.  The data is similar to the following:

 

CodeEnd DateAging Bucket (DAX)
16/29/2020Past Due
210/29/2021Beyond 4 months
35/31/2020Past Due
44/29/2021One month

 

I'd like to be able to display:

Aging BucketsCount of Code
Past Due2
One Month1
Beyond 4 months1

 

The problem seems to be putting the Buckets in the rows of the matrix.  In my situation using SSAS, I'm haven't found a way to create a table and use it.  (I'm not sure why other than it might have something to do with using a direct connection to the SSAS Tabular model.)

 

My Categories were created with the following:

 

Aging Buckets =
VAR Latest =
    MAXX ( 'Dimension1', 'Dimension1'[End Date] )
VAR Bucket =
    CALCULATE (
        IF (
            Latest,
            IF (
                HASONEVALUE ('Dimension1'[End Date]),
                SWITCH (
                    TRUE,
                    [NO of days] <= 0, "Past Due",
                    [NO of days] > 0
                        && [NO of days] <= 30, "One Month",
                    [NO of days] > 30
                        && [NO of days] <= 60, " Two Months",
                    [NO of days] > 60
                        && [NO of days] <= 90, " Three Month",
                    [NO of days] > 90
                        && [NO of days] <= 120, " Four Month",
                    "More Than 4 Months"
                )
            )
        )
    )
RETURN
    Bucket

 

 

Days past due:

 

NO of days = 
VAR TD = TODAY()
VAR ED = SELECTEDVALUE('Dimension1'[End Date])
RETURN
IF (TD < ED, DATEDIFF(TD,ED,DAY), DATEDIFF(ED,TD,DAY) * -1)

 

 

Count of Codes:

 

Aging Count = CALCULATE(COUNTAX('Dimension1','Dimension1'[Code]))

 

 

How do I use it in a matrix to group the aging counts by each bucket?

 

Thanks.

1 ACCEPTED SOLUTION

Hi @msatterwhite ,

 

Yes,you cant put measure in rows,could you use "No of days" instead?

Such as below:

v-kelly-msft_0-1618281488564.png

If you need the column "No of days" showing in matrix ,you could hide it by tricks:Go to column headers>switch "word wrap":off

v-kelly-msft_1-1618282176332.png

 

You could check my updated .pbix file attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

View solution in original post

8 REPLIES 8
v-kelly-msft
Community Support
Community Support

Hi @msatterwhite ,

 

Create a measure as below:

measure = 
CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Aging Buckets]=MAX('Table'[Aging Buckets])))

And you will see:

v-kelly-msft_0-1618193918072.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Thank you for your response.  I think I'm running into difficulty doing this while using a live-connection to SSAS.  No matter what I try, I'm unable to put the Aging Buckets in the rows.  It won't allow me to move it there.


In your visual, you were able to put Aging Buckets in the Rows:

msatterwhite_0-1618250736634.png

 

But, the best I can get is for both measures to land in the Values.

msatterwhite_1-1618250965952.png

 

I used the same measures you used. 

Have you tried to create use the measures when using a direct-connection to SSAS?

A potential clue is shown when I use your .pbix file and try to make an additional connection to SSAS.  I'm only able to connect using Import, which my users don't want to do.

msatterwhite_2-1618251207029.png

 

Hi @msatterwhite ,

 

Yes,you cant put measure in rows,could you use "No of days" instead?

Such as below:

v-kelly-msft_0-1618281488564.png

If you need the column "No of days" showing in matrix ,you could hide it by tricks:Go to column headers>switch "word wrap":off

v-kelly-msft_1-1618282176332.png

 

You could check my updated .pbix file attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

Unfortunately, I'm still unable to use your solution.  In your solution, you have a column for NO of days that isn't calculated.  I have to calculate my NO of days as a measure built by subtracting my [End Date] column from today.  That's preventing me from being able to use NO of days as a row or column in a matrix.  

 

The only columns I get from my SSAS model are Category and End Date.  Are you able to find a way to get a matrix to display the same way if everything in it is a measure?

Hi @msatterwhite ,

 

How do you like the solution as below:

v-kelly-msft_0-1619662898690.png

As only measure is available,if you dont have  a key column to summarize the [_Aging Buckets],then it would show similarly as above.

The measure is as below:

measure = 
var tab=SUMMARIZE('Table','Table'[Category],"aging",[_Aging Buckets])
Return
COUNTX(tab,[aging])

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Thanks Kelly.  That's the best I was able to do as well.  I was hoping to make it a summarized view of the data but it sounds like that's not possible with each of those fields being measures.  

 

I appreciate your continued help.  I needed that confirmation.

amitchandak
Super User
Super User

@msatterwhite , actually to do measure bucketing you need to use an independent date table. As you are using SSAS, you might have go few things at SSAS only

 

I have explained bucketing here :https://youtu.be/CuczXPj0N-k

 

or refer these

https://www.daxpatterns.com/dynamic-segmentation/
https://radacad.com/grouping-and-binning-step-towards-better-data-visualization

Thank you for your response.  I've been trying to use the technique from your video and the links you provided but I'm unable to put my Buckets measure in the Rows area.  I think my direct-connection to SSAS prevents me from being able to use the Buckets measure the way I want to.  

Have you tried your approach when using a "Connect-live" connection to SSAS?  I'm curious to know if it works.

Thanks.

Please see my reply to v-kelly-msft above, which goes into more detail.

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.