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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Narukkp
Helper V
Helper V

Drill Down on Different measures on Matrix

Hi Team,

I have the data as below data format and required the output as first level total sum required, second level each state wise percentage out of total , 3rd level each district wise percentage out of state total wise. For data and required output please find below sample formats

 

Data
StateDistrictBranchValue
State1District1Br14
State1District1Br26
State1District2Br315
State1District2Br45
State2District3Br53
State2District3Br66
State2District4Br77
State2District4Br84
State3District5Br910
State3District5Br1020
State3District6Br1114
State3District7Br128
Required Output
Total102
 State129% 
  District133%
  District267%
 State220% 
  District345%
  District455%
 State351% 
  District558%
  District642%
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @Narukkp ,

 

Please refer to the measure below and see if the result achieve your expectation.

Measure = 
var district = CALCULATE(SUM(Data[Value]),ALLEXCEPT(Data,Data[District]))
var state = CALCULATE(SUM(Data[Value]),ALLEXCEPT(Data,Data[State]))
var total = CALCULATE(SUM(Data[Value]),ALL(Data))
var selected_state = SELECTEDVALUE(Data[State])
var selected_discrict = SELECTEDVALUE(Data[District])
return
IF(ISBLANK(selected_state)&&ISBLANK(selected_discrict),total,IF(ISBLANK(selected_discrict),FORMAT(state/total,"percent"),FORMAT(district/state,"percent")))

Result would be shown as below.

1.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

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

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

View solution in original post

4 REPLIES 4
v-jayw-msft
Community Support
Community Support

Hi @Narukkp ,

 

Please refer to the measure below and see if the result achieve your expectation.

Measure = 
var district = CALCULATE(SUM(Data[Value]),ALLEXCEPT(Data,Data[District]))
var state = CALCULATE(SUM(Data[Value]),ALLEXCEPT(Data,Data[State]))
var total = CALCULATE(SUM(Data[Value]),ALL(Data))
var selected_state = SELECTEDVALUE(Data[State])
var selected_discrict = SELECTEDVALUE(Data[District])
return
IF(ISBLANK(selected_state)&&ISBLANK(selected_discrict),total,IF(ISBLANK(selected_discrict),FORMAT(state/total,"percent"),FORMAT(district/state,"percent")))

Result would be shown as below.

1.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

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

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

Hi @ v-jayw-msft Thanks you so much for your solution

amitchandak
Super User
Super User

You can try isfiltered

 

if(ISFILTERED([District]),formula1, formula2)

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog -

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...


https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...

https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
rajulshah
Memorable Member
Memorable Member

Hello @Narukkp,

 

Please try the following DAX query:

Measure% = 
VAR SelectedDistrict = SELECTEDVALUE('State Data'[District])
VAR SelectedState = SELECTEDVALUE('State Data'[State])
VAR TotalValue = SUM('State Data'[Value])
VAR TotalValueDistrict = CALCULATE(SUM('State Data'[Value]),ALL('State Data'[District]))
VAR TotalValueState = CALCULATE(SUM('State Data'[Value]),ALL('State Data'[State]))
VAR StatePercentage = FORMAT(DIVIDE(TotalValue,TotalValueState),"Percent")
VAR DistrictPercentage = FORMAT(DIVIDE(TotalValue,TotalValueDistrict),"Percent")
RETURN
IF(ISBLANK(SelectedDistrict) && ISBLANK(SelectedState),TotalValue,IF(ISBLANK(SelectedDistrict),StatePercentage,DistrictPercentage))

Hope this helps.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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