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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
sportive92003
Helper II
Helper II

calculate or switch?

Hello,

 

In the formula, the first CALCULATE after the RETURN gives the results, but I can't reproduce for the 2 seconds CALCULATE. Any solution? Seems so easy but I can't reach.

 

Secteur_BNAC =
VAR A = CALCULATE([Montant Measure],Fusionner1[Clients.Secteur ] = "01 -Machinerie et travaux")
VAR B = CALCULATE([Montant Measure],Fusionner1[Clients.Secteur ] = "02 -Marine et portuaire")
VAR C = CALCULATE([Montant Measure],Fusionner1[Clients.Secteur ] = "03 -Hydroélectrique")
VAR Montant_BNAC = IF('Fusionner1'[Secteur 20%] = 1, 'Fusionner1'[montant] / 3, BLANK() )
VAR A_BNAC = (A+Montant_BNAC)
VAR B_BNAC = (B+Montant_BNAC)
VAR C_BNAC = (C+Montant_BNAC)
RETURN
CALCULATE(A_BNAC,'Fusionner1'[Clients.Secteur ] = "01 -Machinerie et travaux")
 
/*CALCULATE(B_BNAC,'Fusionner1'[Clients.Secteur ] = "02 -Marine et portuaire")
CALCULATE(C_BNAC,'Fusionner1'[Clients.Secteur ] = "03 -Hydroélectrique")*/
 
And for others sectors, just use the amount (Montant Measure).
 
Thanks.
1 REPLY 1
MattAllington
Community Champion
Community Champion

Variables in DAX are not variable. It would be better if they were called constants. Once you assign a value it cannot be changed. As a result, you cannot use variables as the first parameter inside CALCULATE as that parameter is the one that is modified by the filter parameters. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.