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

Percent of Column Total and drilling

Hi

 

i had a similar question answered here  - Question , but now i need to make a drill also on the columns , and the number just got all wrong.

 

my data set is (simpiflied for the question):

 

PriorityNumber of registrantsSCHOOLFACULTYSECTIONDATE
1st10X1A1.1.2018
2nd20X1A1.1.2018
1st32X1A5.1.2018
2nd40X1A5.1.2018
1st40Y2B1.1.2018
2nd80Y2B1.1.2018
1st60Y2B5.1.2018
2nd20Y2B5.1.2018


i want a matrix visual of the following :

 

 Date
 5.1.20181.1.2018
 PriorityPriority
Section1st 2ndTotal1st 2ndTotal
A220%100%140%0%0%0%
B50%-75%-33%0%0%0%

 

 

using the code:

 

% registrants = 

VAR previousDate =

    CALCULATE (

        MAX ( MyTable[Date] ),

        FILTER ( ALLSELECTED ( MyTable), MyTable[Number of registrants] > 0 &&  MyTable[Date]< MAX ( MyTable[Date] ) )

    )

VAR previousREG =

    CALCULATE (

        SUM ( MyTable[Number of registrants] ),

       FILTER ( ALLEXCEPT(MyTable,MyTable[SECTION]) ,mytable[prioirty] ,  MyTable[Date]= previousDate )

    )

RETURN

           DIVIDE( SUM ( MyTable[Number of registrants] ) -previousReg,previousReg,0)

 

However it seems that the drill on the column size is not affected although i wrote the priority column on the FILTER ALLEXCEPT dax statement for some reason...

 

instead of calc of ( SECTION A ; Prioirty 1st)  :(32-10)/10  = 220% it actually calc  (32-30)/30 . it seems that the (FILTER(ALLEXCEPT) dax statement is missing something on the column side, and instead of sum only the part of the prioirty , it sums the total (1st + 2nd) . how can i enforce powerbi to sum only the priority and not the total of priority ?

 

 

Help is appreciated

Elad

 

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi, @ellevy12

After my test, you need to improve your formula as below:

% registrants = 

VAR previousDate =

    CALCULATE (

        MAX ( MyTable[Date] ),

        FILTER ( ALLSELECTED ( MyTable), MyTable[Number of registrants] > 0 &&  MyTable[Date]< MAX ( MyTable[Date] ) )

    )

VAR previousREG =

    CALCULATE (

        SUM ( MyTable[Number of registrants] ),

       FILTER ( ALLEXCEPT(MyTable,MyTable[SECTION],MyTable[Priority]),MyTable[DATE]= previousDate )

    )

RETURN

         var result=  DIVIDE( SUM ( MyTable[Number of registrants] ) -previousReg,previousReg,0) return
result

CALCULATE (

SUM ( MyTable[Number of registrants] ),

FILTER ( ALLEXCEPT(MyTable,MyTable[SECTION],MyTable[Priority]) , MyTable[Date]= previousDate )

)

 

you can also add other conditions in it.

 

Because you had added new conditional MyTable[Priority] into matrix visual, so you need to add this conditional into your

formula too.

Result:

15.JPG

 

and for your reply "how can i not display the min date ? since it's all 0 anyway due to not have diffrence of change "

I have test a lot for it, I'm afraid it couldn't achieve for now. The simplest method is filter it by slicer.

Sorry for the late reply for it.

 

 

Best Regards,

Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-lili6-msft
Community Support
Community Support

hi, @ellevy12

After my test, you need to improve your formula as below:

% registrants = 

VAR previousDate =

    CALCULATE (

        MAX ( MyTable[Date] ),

        FILTER ( ALLSELECTED ( MyTable), MyTable[Number of registrants] > 0 &&  MyTable[Date]< MAX ( MyTable[Date] ) )

    )

VAR previousREG =

    CALCULATE (

        SUM ( MyTable[Number of registrants] ),

       FILTER ( ALLEXCEPT(MyTable,MyTable[SECTION],MyTable[Priority]),MyTable[DATE]= previousDate )

    )

RETURN

         var result=  DIVIDE( SUM ( MyTable[Number of registrants] ) -previousReg,previousReg,0) return
result

CALCULATE (

SUM ( MyTable[Number of registrants] ),

FILTER ( ALLEXCEPT(MyTable,MyTable[SECTION],MyTable[Priority]) , MyTable[Date]= previousDate )

)

 

you can also add other conditions in it.

 

Because you had added new conditional MyTable[Priority] into matrix visual, so you need to add this conditional into your

formula too.

Result:

15.JPG

 

and for your reply "how can i not display the min date ? since it's all 0 anyway due to not have diffrence of change "

I have test a lot for it, I'm afraid it couldn't achieve for now. The simplest method is filter it by slicer.

Sorry for the late reply for it.

 

 

Best Regards,

Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.