Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
SEDE
Microsoft Employee
Microsoft 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?

SEDE
Microsoft Employee
Microsoft Employee

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.