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
SEDE
Employee
Employee

Count Permutations Within a Column Based on Slicer (DirectQuery Model)

Hello All!

 

Very new to Power BI here, but I hope you all can help.

 

I had set up some sample data to experiment with for getting the result I hoped for. I thought I got it, but then when applying it to my real data, I end up with a “Function 'CALCULATE' is not allowed as part of calculated column DAX expressions on DirectQuery models” error. So it looks like I’m back to the drawing board!

 

I’m basically trying to count permutations within my data based on selections in a slicer. You can see the functionality here:

 

SEDE_1-1618614069320.png

Here’s my sample data:

 

Clothes:

Form IDQuestionAnswer
A32fColorRed
A32fFitTight
A32fStyleLow Cut
G34dColorBlue
G34dFitTight
G34dStyleHigh Waist
K86pColorRed
K86pFitLoose
K86pStyleHigh Waist

 

With a lot of googling and fiddling, I ended up with two measures and a calculated column.

 

(Measure 1) CountAnswers: 

 

CountAnswers = 
VAR _NoSelection =
    NOT CALCULATE ( ISFILTERED ( Clothes[Answer] ), ALLSELECTED ( Clothes[Answer] ) )
RETURN
    IF (
        NOT ( _NoSelection ),
        IF (
            CALCULATE ( DISTINCTCOUNT ( Clothes[Answer] ), ALLSELECTED ( Clothes[Answer] ))
               = COUNTROWS ( ALLSELECTED ( Clothes[Answer] ) ),
            1
        )
    )

 

 

(Measure 2) CountAnswersTotal:

 

CountAnswersSUM = 
    SUMX ( DISTINCT ( Clothes[Form ID] ), [CountAnswers] )

 

 

(Column) Combined:

 

Combined = CALCULATE(CONCATENATEX(Clothes,Clothes[Answer], ", "), FILTER(ALL(Clothes),Clothes[Form ID] = EARLIER(Clothes[Form ID])))

 

 

Is there any way to recreate the functionality here that will work on DirectQuery model?

 

Thanks!

2 REPLIES 2
lbendlin
Super User
Super User

Does the result have to come from a single table or can the slicer be fed from a disconnected table?

Hi Ibendlin,

 

In theory I can do whatever I need to do with manipulating the data layout as long as the data itself is good. It does currently all reside in one table with many columns, though I only need the three listed above for this, (I assume).

 

Thanks! I appreciate any direction you can give.

 

SEDE

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