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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Memorable Member
Memorable Member

@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
Memorable Member
Memorable Member

@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
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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