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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.