Forum Discussion

619SK's avatar
619SK
Helper II
2 years ago
Solved

Power Query formula for calculating if condition and calculate count from another table

Hi I have around 20+ controls from each sharepoint, i need to calculate count with open status and give point as per ageing per the rules. i have appended all 20+ control into 1 table with two colu...
  • Greg_Deckler's avatar
    Greg_Deckler
    2 years ago

    619SK I put this solution together. Might be correct I suppose. I did some things in Power Query but the rest is DAX. See PBIX attached below signature. Really the only Power Query is unpivoting your point logic columns.

    Open = 
        VAR __AgeCategory = MAX( 'PointLogic'[Attribute] )
        VAR __Table = 
            ADDCOLUMNS(
                'Table',
                "AgeCategory",
                    SWITCH( TRUE(),
                        [Ageing] < 16, "0-15",
                        [Ageing] < 31, "16-30",
                        [Ageing] < 91, "31-90",
                        ">90"
                    )
            )
        VAR __Result = COUNTROWS( FILTER( __Table, [AgeCategory] = __AgeCategory ) ) + 0
    RETURN
        __result
    
    
    
    
    Points = 
        VAR __Open = [Open]
        VAR __AgeCategory = MAX( 'PointLogic'[Attribute] )
        VAR __Result = MAXX( FILTER( 'PointLogic', [No of Count] = __Open && [Attribute] = __AgeCategory ), [Value] )
    RETURN
        __Result