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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
ddent1406
New Member

Sum from results of IF / AND Measure

Good Morning.. 

I've written a a quick DAX statement to give me the results i need on line by line basis

C_TerminalsNotTagging = If(AND(CALCULATE(FACT_AML_SSBT_DAILY_SESSIONS_DATA[NickNameCount])<1,Count(__DIM_Terminals[Dim_Terminal_Key]) >0),1,0) 
Which gives me the output below..
ddent1406_0-1652174443575.png

 

What i would now like to do is either sum or count the 1 in that column to give me the total of 2.. However, either i'm having a really bad day or this is more difficult than i 1st thought.. 

Any help would be appreciated.







1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@ddent1406 the general answer is to wrap your measuere with SUMX.
The important thing is what to put in the first statement and that is depandant on your model and desired visual.
For a specific visual you need to put all the columns that play affect in the matrix rows, and if they come from different tables you need to use for example summarize like what I wrote.
Hard to say without seeing your model and which are the relevant columns in your matrix / table visual but I wrote here the general code for that and see if you can easily adjust to your column names:

 

 

C_TerminalsNotTagging = 
SUMX(
   SUMMARIZE (
   		FACT_AML_SSBT_DAILY_SESSIONS_DATA,
   		Dim1[Column 1],
   		Dim2[Column 2],
   		... ,
   		... ,
   		... ,
   		FACT_AML_SSBT_DAILY_SESSIONS_DATA[Column3]
   	),
	If(AND(CALCULATE(FACT_AML_SSBT_DAILY_SESSIONS_DATA[NickNameCount])<1,Count(__DIM_Terminals[Dim_Terminal_Key]) >0),1,0)
)

 

 




2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

3 REPLIES 3
SpartaBI
Community Champion
Community Champion

@ddent1406 the general answer is to wrap your measuere with SUMX.
The important thing is what to put in the first statement and that is depandant on your model and desired visual.
For a specific visual you need to put all the columns that play affect in the matrix rows, and if they come from different tables you need to use for example summarize like what I wrote.
Hard to say without seeing your model and which are the relevant columns in your matrix / table visual but I wrote here the general code for that and see if you can easily adjust to your column names:

 

 

C_TerminalsNotTagging = 
SUMX(
   SUMMARIZE (
   		FACT_AML_SSBT_DAILY_SESSIONS_DATA,
   		Dim1[Column 1],
   		Dim2[Column 2],
   		... ,
   		... ,
   		... ,
   		FACT_AML_SSBT_DAILY_SESSIONS_DATA[Column3]
   	),
	If(AND(CALCULATE(FACT_AML_SSBT_DAILY_SESSIONS_DATA[NickNameCount])<1,Count(__DIM_Terminals[Dim_Terminal_Key]) >0),1,0)
)

 

 




2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

 

Hi SpartaBI , 
worked great , had to chnage the if statement around a bit.. but got the result i wanted. 

ddent1406_0-1652187278677.png

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors
Top Kudoed Authors