Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi
What is the best way to transfer the logic from excel like below to Power BI either in Power Query or in DAX ? Many thanks
=(COUNTIF(A2:D2,"X")+COUNTIF(A2:D2,"XY"))/(COUNTIF(A2:D2,"X")+(COUNTIF(A2:D2,"XY") + (COUNTIF(A2:D2,"XYZ")
Solved! Go to Solution.
Hi @dimsandfacts ,
Check if this is your expected output:
Column =
VAR _Count_X =
CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column1] = "X" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column2] = "X" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column3] = "X" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column4] = "X" )
VAR _Count_XY =
CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column1] = "XY" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column2] = "XY" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column3] = "XY" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column4] = "XY" )
VAR _Count_XYZ =
CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column1] = "XYZ" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column2] = "XYZ" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column3] = "XYZ" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column4] = "XYZ" )
RETURN
DIVIDE ( _Count_X + _Count_XY, _Count_X + _Count_XY + _Count_XYZ )
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi @dimsandfacts ,
Check if this is your expected output:
Column =
VAR _Count_X =
CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column1] = "X" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column2] = "X" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column3] = "X" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column4] = "X" )
VAR _Count_XY =
CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column1] = "XY" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column2] = "XY" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column3] = "XY" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column4] = "XY" )
VAR _Count_XYZ =
CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column1] = "XYZ" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column2] = "XYZ" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column3] = "XYZ" )
+ CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Column4] = "XYZ" )
RETURN
DIVIDE ( _Count_X + _Count_XY, _Count_X + _Count_XY + _Count_XYZ )
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
@dimsandfacts See if this helps: (1) Excel to DAX Translation - Microsoft Fabric Community
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
63 | |
62 | |
52 | |
39 | |
24 |
User | Count |
---|---|
84 | |
57 | |
45 | |
42 | |
37 |