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

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

Reply
Aazam
Helper I
Helper I

Calculate Column Value in Dax

Hello,

I have a problem with my DAX, Let me try to clear the scenario, I am creating a template for my report.

I am using Switch Cases to place values Calculation Daxs in my table. But I want Quarter Variance from my templet table (pic is below), So I am trying to create a DAX of Quarter Variance in which I want the Variance of *Last 2 Quarters in my Table column "Variance Quarter" (I am using switch case for that). I am unable to get values from Quarters.
(Note I am trying to get a variance of the Last 2 quarters which means if 2023 is selected it will get a variance of Q3 - Q2)

 
My Variance DAX:

MemberCount(Quarter Variance) = 
 
SUMX(
    SUMMARIZE(
        'Member Group DC - Calendar',' Member Group DC - Calendar'[ColumnInUse]),
var quat =
    CALCULATE([membercountHistory],FILTER('Member Group DC - Calendar','Member Group DC - Calendar'[ColumnInUse] = "Q4"))

var quat_1 = 
    CALCULATE([membercountHistory],FILTER('Member Group DC - Calendar','Member Group DC - Calendar'[ColumnInUse] = "Q3"))
var vari = quat - quat_1
return
vari
)


My Switch Case:

Templet case = 

Var mmcount = [membercountHistory]
Var selectvalue = SELECTEDVALUE( 'Member Group DC - Calendar'[order])
var ytdvariance = [membercountHistory] - [LY_membercountHistory]
var lastyear = [MemberCount(LYYTD)]
var quarter2 = [MemberCount(Quarter Variance)]

 VAR result_print = 
 SWITCH (
        
        selectvalue,
        7,ytdvariance,
        8,lastyear,
        6,quarter2,
       mmcount
        )


My Visual

Aazam_3-1693490293016.png

 

Aazam_1-1693490189935.png

Aazam_2-1693490237140.png

 

 

1 REPLY 1
DataNinja777
Super User
Super User

Hi @Aazam,

It seems like you are not using the separate calendar table in your data model which has relationship with your fact table.  Is that right?  I think using the calender table and time intelligence functions will simplify your task.  

 

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.