DAX measure used declared as variable as opposed to being referred to directly in another measer

dicken

Active Member
Joined
Feb 12, 2022
Messages
283
Office Version
  1. 365
Platform
  1. Windows
HI,
I wanted to create a number sequence with dax , so started with ;
Excel Formula:
Onevalue:=IF( HASONEVALUE(Table1[Date]),VALUES(Table1[Date]))


I then used this in another measure ;

Excel Formula:
Index :=
CALCULATE (
    COUNTROWS ( Table1 ),
    FILTER ( ALL ( Table1 ), ISONORAFTER ( Table1[Date], [Onevalue], DESC ) )
)


But this gave a count of the total, but when I made the [Onevalue] measure a variable it worked fine;

Excel Formula:
IndexVAR :=
VAR onev = [Onevalue]
RETURN
             CALCULATE(
                             COUNTROWS(Table1),
                                    FILTER(ALL(Table1),ISONORAFTER(Table1[Date], onev, DESC) ))


I did put these into DAX studio, and got in this case 14 and 0, can someone explain or point in the direction of information on how these two measure are
filtering down to different results. is you use ; IF( HASONEVALUE(Table1[Date]),VALUES(Table1[Date])) inside the second formula again it works.

Richard
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,215,073
Messages
6,122,975
Members
449,095
Latest member
Mr Hughes

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top