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
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
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.