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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
MiMich
New Member

DAX formula

Hello everybody,

 

Here is the situation :

I've got a table like this :

MiMich_0-1722503254890.png

I'd like to build this matrix in Power BI:

MiMich_1-1722503387690.png

There is also a filter on the client. 

So if I select for example client A the matrix must be :

MiMich_3-1722503556239.png

 

Please could you help me.

 

Thanks all.

 

 

1 ACCEPTED SOLUTION
BeaBF
Super User
Super User

@MiMich Hi! Here the measure to achieve the result:

EventPercentage =
VAR SelectedYear = SELECTEDVALUE('Table'[Year])
VAR SelectedCategory = SELECTEDVALUE('Table'[Category])
VAR SelectedTypeEvent = SELECTEDVALUE('Table'[Type Event])
VAR SelectedClient = SELECTEDVALUE('Table'[Client])
VAR TotalEvents = CALCULATE(SUM('Table'[#Event]), 'Table'[Category] = SelectedCategory,  'Table'[Year] = SelectedYear, ALL('Table'[Type Event]))
VAR TotalEventsByYearAndType = CALCULATE(SELECTEDVALUE('Table'[#Event]), 'Table'[Category] = SelectedCategory,  'Table'[Year] = SelectedYear, 'Table'[Type Event] = SelectedTypeEvent, 'Table'[Client] = SelectedClient)

VAR CALC =
IF(
    TotalEvents = 0,
    BLANK(),
    DIVIDE(TotalEventsByYearAndType * 100, TotalEvents * 100, 0)
)

RETURN CALC

BeaBF_1-1722506418782.png

 

also interacts with client slicer:

BeaBF_2-1722506440702.png

 

if it's oki, please accept my answer as solution.

 

BBF


View solution in original post

2 REPLIES 2
sjoerdvn
Super User
Super User

en % Magasin vs Web = 
VAR v = CALCULATE(SUM(Table[#ventes]), ALL(Table[Type vente]))
RETURN IF(v, DIVIDE(SUM(Table[#ventes]),v))
BeaBF
Super User
Super User

@MiMich Hi! Here the measure to achieve the result:

EventPercentage =
VAR SelectedYear = SELECTEDVALUE('Table'[Year])
VAR SelectedCategory = SELECTEDVALUE('Table'[Category])
VAR SelectedTypeEvent = SELECTEDVALUE('Table'[Type Event])
VAR SelectedClient = SELECTEDVALUE('Table'[Client])
VAR TotalEvents = CALCULATE(SUM('Table'[#Event]), 'Table'[Category] = SelectedCategory,  'Table'[Year] = SelectedYear, ALL('Table'[Type Event]))
VAR TotalEventsByYearAndType = CALCULATE(SELECTEDVALUE('Table'[#Event]), 'Table'[Category] = SelectedCategory,  'Table'[Year] = SelectedYear, 'Table'[Type Event] = SelectedTypeEvent, 'Table'[Client] = SelectedClient)

VAR CALC =
IF(
    TotalEvents = 0,
    BLANK(),
    DIVIDE(TotalEventsByYearAndType * 100, TotalEvents * 100, 0)
)

RETURN CALC

BeaBF_1-1722506418782.png

 

also interacts with client slicer:

BeaBF_2-1722506440702.png

 

if it's oki, please accept my answer as solution.

 

BBF


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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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